Command Function
head used to display the first few records (10 records by default)
head stud Displays first 10 records by default
head -5 stud Displays first 5 records
head -1 stud | wc –c length of first record
tail used to display the last few records (10 records by default)
tail stud Displays last 10 records by default
tail -5 stud | tee last5 Last 5 records listed & stored in file last5 using tee
cutused to extract specific field The d option specifies the delimiter and f for specifying the field list. The c option may be used if extraction is done character wise
cut –d \| -f 1,3,4 stud Fields 1,3,4 listed
cut –d \| -f 2-4 stud Fields 2,3,4 listed
paste –d \| list1 list2 merges two cut files list1 and list2
sort reorders the file as per ASCII sequence. The t option is used to specify delimiter and k option to specify the field
sort stud Sorted on 1st column by default
sort –t \| -k 3 stud Sort as per 3rd column
sort –c stud Check if file is sorted using c option
sort -t \| -k 4,4 -k 3,3
stud
Sorting on secondary keys
sort -t \| -nr –k 4 stud Sort on numeric field using n option, r for reverse
uniq stud Display unique entries in a sorted file
trtranslates characters. Can be used to change text case. It works with standard input <
tr '[a-z]' '[A-Z]' < stud Changes text to upper case
nldisplay file content with lines numbered. The s option is used to specify separator
nl –s "|" stud Displays entries numbered with separator |
head used to display the first few records (10 records by default)
head stud Displays first 10 records by default
head -5 stud Displays first 5 records
head -1 stud | wc –c length of first record
tail used to display the last few records (10 records by default)
tail stud Displays last 10 records by default
tail -5 stud | tee last5 Last 5 records listed & stored in file last5 using tee
cutused to extract specific field The d option specifies the delimiter and f for specifying the field list. The c option may be used if extraction is done character wise
cut –d \| -f 1,3,4 stud Fields 1,3,4 listed
cut –d \| -f 2-4 stud Fields 2,3,4 listed
paste –d \| list1 list2 merges two cut files list1 and list2
sort reorders the file as per ASCII sequence. The t option is used to specify delimiter and k option to specify the field
sort stud Sorted on 1st column by default
sort –t \| -k 3 stud Sort as per 3rd column
sort –c stud Check if file is sorted using c option
sort -t \| -k 4,4 -k 3,3
stud
Sorting on secondary keys
sort -t \| -nr –k 4 stud Sort on numeric field using n option, r for reverse
uniq stud Display unique entries in a sorted file
trtranslates characters. Can be used to change text case. It works with standard input <
tr '[a-z]' '[A-Z]' < stud Changes text to upper case
nldisplay file content with lines numbered. The s option is used to specify separator
nl –s "|" stud Displays entries numbered with separator |
No comments:
Post a Comment