Linux cut command

cut command is used to cut part of the text. We tell the cut what is the delimiter between the different part of the text and what field we want and it will print only the specific field.
The structure is:
cut  -d  <delimiter>  -f <field-number> <file-name>
For example, in the passwd file, the second field is always x, and indeed:


oren@oren-computer:~/workspace/scripts/python  
$ cut -d : -f 2 /etc/passwd
x
x
x
x
x
x
x

We can show more than one field, by using comma.
The structure:
cut  -d  <delimiter>  -f <field-number1>,<field-number2>  <file-name>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s