IN THIS CHAPTER
Matching text with regular expressions
Editing text files with vi, JOE, or nano
Using graphical text editors
Listing text with cat, head, and tail
Paging text with less and more
Paginating text with pr
Searching for text with grep
Counting words, lines, and characters with wc
Sorting output with sort
Stream editing with sed, tr, cut, and awk
Searching binaries for text with strings
Finding differences in files with diff
Converting text files with unix2dos/dos2unix
With only a shell available on the first UNIX systems (on which Linux was based), using those systems meant dealing primarily with commands and plain text files. Documents, program code, configuration files, e-mail, and almost anything you created or configured was represented by text files. To work with those files, early developers created many text manipulation tools.
Despite having graphical tools for working with text, most seasoned Linux users find command line tools to be more efficient and convenient. Text editors such as vi (vim), Emacs, JOE, nano, and Pico are available with most Linux distributions. Commands such as grep, sed, and awk can be used to find, and possibly change, pieces of information within text files.
This chapter shows you how to use many popular commands for working with text files in Ubuntu. It also explores some of the less common uses of text manipulation commands that you might find interesting.
Many of the tools ...