contd..
Here is a sample csv file
1. Print columns from a csv file
awk -F "," '{print $1}' abc.csv
awk -F "," '{print $1 " " $3}' abc.csv
Where -F defines the seperator.
There is an alternate method to use the field separator
Here FS is used to define the filed separator which is “,” in
this case it could be a whitespace , a tab etc.
2. Display Content of the file without displaying header
awk 'NR!=1 {print $1 " " $2}' abc.txt
awk 'NR>2 {print $1 " " $2}' abc.txt
Where NR indicates the row number
3. Saving AWK output to a separate file
Comments
Post a Comment