Use of Cut Command

Hi All,

Can anyone tell me how to use cut command?I have tried but its not working...Please find the details below :

$ cat file1
SlNo. E_ID E_Name Age Dept
1 123 A 20 Electrical
2 124 B 20 Electronics
3 125 C 24 Computer
4 126 D 23 Mechanical

$ cut -f 1,3 -d : file1
SlNo. E_ID E_Name Age Dept
1 123 A 20 Electrical
2 124 B 20 Electronics
3 125 C 24 Computer
4 126 D 23 Mechanical

Regards ,
Puja

you don't have ":" in your file so you can't use it as delimiter!

You obviously use a single space as your field delimiter, so the command should look like:

cut -f1,3 -d' ' file

which will get you the first and third field. You can also use character boundaries instead of delimiters:

cut -c15-17 file

will cut the fifteenth, sixteenth and seventeenth character and display these three characters from every line as output. Find more of this info at the "fountain of arcane UNIX knowledge", aka "man page".

I hope this helps.

Actually, that would be man cut in this case.

FYI: man [command] displays help and technical manual type info for just about every command.