-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

The Ultimate Linux Shell Scripting Guide
By :

As its name implies, this handy utility is used to cut and display selected information from a text file. Think of it as something that will take a vertical slice of a text file and send it to the output of your choice. There are two ways to specify where you want to begin and end the slice. You can specify it either by specifying the starting and ending characters, or by specifying the fields.
To specify your slice by fields, you’ll need to use both the -d
and -f
switches. The -d
switch will specify the delimiter, the character that separates the fields. That’s so that cut
will know where each field begins and ends. The -f
switch will specify which fields you want to look at. In this diagram, you see that I used cut
to extract the user name and real name--fields 1
and 5
--from the /etc/passwd
file.
Figure 6.3: Using cut to view fields 1 and 5 of the passwd file
Since the fields in this file are separated by colons, I used -d:
for the delimiter...