The cut command in Unix/Linux is used to extract sections from each line of a file or input stream. It is particularly useful for working with delimited text files, where fields are separated by a specified delimiter character.
Here are some common options: -f or --fields: Specify the fields to extract. You can provide a comma-separated list of field numbers or a range (e.g., -f 1,3 or -f 1-3). -d or --delimiter: Specify the field delimiter character. The default delimiter is the tab character. -c or --characters: Specify the characters to extract. This can be a comma-separated list of character positions or a range (e.g., -c 1,3 or -c 1-3).
cut -d',' -f1,3 filename.csv
cut -f2-5 -d$'\t' filename.tsv
cut -d' ' -f2 filename.txt
cut -d',' -c3- filename.csv
cut -d':' -f2 filename.txt
cut -d' ' -f1,3 filename.txt
echo "123-456-789" | cut -d'-' -c2-
cut -d'_' -f3 filename.txt
cut -d',' -c1,3,5 filename.csv
cut -d':' -c1-5 filename.txt
cut -d' ' -c3-8 filename.txt
cut -f2,4,6 -d$'\t' filename.tsv
cut -d',' -c2,5-7 filename.csv
cut -d'-' -f1,3 filename.txt
cut -d':' -c2-8 filename.txt
cut -d' ' -f6 filename.txt
cut -d',' -f2,4 filename.csv
cut -f2-5 -d$'\t' filename.tsv
cut -d',' -c2-6 filename.csv
cut -d' ' -c4-10 filename.txt