'What is the result supposed to be of the command "cut -f 1,2 list.txt"?

I tried using the command cut -f 1,2 list.txt on a list but for some reason the output of the list it gives me remains the same, I'm not seeing any difference. What is it supposed to do?



Solution 1:[1]

You should be able to read cut's documentation on your machine by typing man cut or info cut (on Gnu Linux systems). If neither of those work, you can find the same documentation on-line, but you will really find it more convenient to have command-tool documentation at your fingertips:

These are all quite similar, since the Posix standard applies; some implementations have additional features, but they should all be based on the Posix standard, which includes the following relevant command-line options:

-d delim
Set the field delimiter to the character `delim`. The default is the <tab>.
-f list
Cut based on a list of fields, assumed to be separated in the file by a delimiter character (see -d). Each selected field shall be output. Output fields shall be separated by a single occurrence of the field delimiter character. Lines with no field delimiters shall be passed through intact, unless -s is specified. It shall not be an error to select fields not present in the input line.

There's a lot more, but that should be enough to answer your question. cut -f1,2 prints fields 1 and 2, where fields are separated by a <tab> character. If there is no tab character in a line (probably the case in your sample inputs), it is passed through intact.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rici