Syntax: cut [OPTION]... [FILE]...
Description: Prints selected parts of lines (of a text file), or, in other words, removes certain sections of a line. You may wish to remove things according to tabs or commas, or anything else you can think of...
Options for cut:
?d ??? allows you to specify another delimiter, for example ':' is often used with /etc/passwd:
cut ?d ':' (and probably some more options here) /etc/passwd
?f ??? this option works with the text by columns, separated according to the delimiter. For
example if your file had lines like "result,somethingelse,somethingelse" and you only wanted
result you would use:
cut ?d ',' ?f 1 /etc/passwd
This would get you only the usernames in /etc/passwd
"," (commas) ??? used to separate numbers, these allow you to cut particular columns. For
cut ?d ':' ?f 1,7 /etc/passwd
This would only show the username and the shell that each person is setup for in /etc/passwd.
"?" (hyphen) ??? used to show from line x to line y, for example 1?4, (would be from lines 1
to line 4).
cut ?c 1?50 file1.txt
This would cut (display) characters (columns) 1 to 50 of each line (and anything else on that
line is ignored)
?x ??? where x is a number, to cut from line 1 to "x"
x? ??? where x is a number, to cut from "x" to the end.
cut ?5, 20?, 8 file2.txt
This would display ("cut") characters (columns) 1 to 5, 8 and from 20 to the end