cut – Splitting a file vertically : NIX Classes

 

The external cut command displays selected columns or fields from each line of a file.

-c     Cutting columns

to cutting specific columns, you need to follow the -c option with a list of column numbers, delimit by a comma. Range can also be used using the hyphen.

$ cut -c 6-22,24-26 emp.list

this command extract the data, from file, from 6th char to 22th and 24th char to 26th characters .

$ cut -c 2,3-4.6-12,15 emp.list

-f      Cutting fields

to extract useful data from these files u need to cut fields rather than columns. Cut use the tab as the default field delimiter, but can also work with a different delimiter. Option -d specified a single character delimiter which serves as field separator.Two option need to be used here : -d for the field delimiter and -f for the field list.

$ cut -d “|” -f2,3 emp.list

it extract the field 2,3 which is delimit by |.

** One of the option -c and -f must be specified. These option are really not optional, one of them is compulsory.
 
 

njoy the simplicity…….
©Victimizeit

Advertisements

About victimizeit
This is Atul.. working for IBM as a DataStage Developer. I may not be an expert on any particular DataStgae technology, but I'm sure I do know a few things about DB2, AIX, Unix, Windows, and DataBase. In this blog, I'll give out some tips on these subjects. If you find them useful, great, I'll be happy. Thanks for stopping by !!

What is your opinion ?

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

%d bloggers like this: