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 BSD 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 BSD distributions. 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 in BSD systems. 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, to identify the text you are ...

Get BSD Unix® Toolbox: 1000+ Commands for FreeBSD®, OpenBSD, and NetBSD® 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.