Chapter 5. Manipulating Text

With only a shell available on the first UNIX systems (on which BSD systems were 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, developers created many text manipulation tools.

Despite having graphical tools for working with text, most seasoned UNIX users find command-line tools to be more efficient and convenient. Text editors such as Vi (Vim), Emacs, Nano, and Pico are available with most BSD distributions, including Mac OS X. Commands such as grep, sed, and awk can be used to find, and possibly change, pieces of information within text files.

This chapter explains how to use many popular commands for working with text files on Mac OS X. It also explores some of the less common uses of text manipulation commands that you might find interesting.

Matching Text with Regular Expressions

Many of the tools for working with text enable you to use regular expressions, sometimes referred to as regex or RegEx, to identify ...

Get MAC OS® X UNIX® Toolbox: 1000+ Commands for the Mac OS® X now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.