Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Text Processing Tools

The tools listed in this section are commonly used for text processing. Unless otherwise noted, these commands take input from standard input (if applicable) and print the result to standard output.

Many of these commands use regular expressions. The syntax of regular expressions is described in “Regular Expressions Unfettered.” For additional usage notes specific to individual applications, see the manual page for the command itself.

Table A-2  Commonly-used text processing tools

Tool

Description

awk

Short for Aho, Weinberger, and Kernighan; a programming language in itself, used for text processing using regular expressions. This is described further in “How awk-ward.”

grep

Short for Global [search for] Regular Expressions and Print; prints lines matching an input pattern (optionally with a specified number of lines of leading and/or trailing context). The grep command can take input from standard input or from files.

Common variants include agrep (“approximate grep” from the Univ. of AZ), fgrep, and egrep.

head

Prints the first few lines from a file (or standard input). The number of lines can be specified with the -n flag.

perl

A programming language whose scripts can be easily embedded in shell scripts using the -e flag. Perl's regular expression language is somewhat richer than basic regular expressions (and easier to read than character classes in extended regular expressions), making it popular for text processing use.

sed

Short for stream editor; performs more complex text substitutions using regular expressions.

sort

Sorts a series of lines. By default, sort reads these lines from its standard input. After its standard input is closed, it sorts them and prints the results to its standard output.

tail

Prints the last few lines from of a file (or standard input). The number of lines can be specified with the -n flag. Alternatively, you can specify the starting position as a byte or line offset from either the start or end of the file.

tee

Copies standard input to standard output, saving a copy into a file (or multiple files).

tr

Replaces one character with another.

uniq

Filters out adjacent lines that match.



< Previous PageNext Page > Hide TOC


Last updated: 2008-04-08




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice