Professional Documents
Culture Documents
Cut, Paste
Cut, Paste
Syntax:
1) cut -c2 filename # Cuts the second character of all lines and prints them
2) cut -c2-5 filename # Cuts characters from 2nd to 5th position and prints them
3) cut -c3- filename # Cuts and prints from 3rd character till the end
4) cut -c-8 filename # cuts from the 1st character till the 8th character and
prints
1) cut -d "," -f2 filename # cuts the 2nd field from the file and prints
2) cut -d "," -f2,3 filename # cuts 2nd and 3frd fields from the file and prints
Suntax:
paste options file-1 file-2 file-n
1) paste filename1 filename2 #merges contents of first file and second file
2) paste -d "," filename1 filemane2 #merges contents of fisrt file and second file
seperating them with a comma
6) cat filename | paste - - - # pastes the 3 lines of the file in a single line