Select specific bytes, characters, or fields from each input line.
cut extracts chosen parts of each line from a file or standard input. It is especially useful for pulling out columns from delimiter-separated text such as CSV-like files, passwd entries, and command output.
# First field, colon-delimited cut -d ':' -f 1 /etc/passwd # First and third fields, comma-delimited cut -d ',' -f 1,3 data.csv
# Extract username field cut -d ':' -f 1 /etc/passwd # Extract columns 1 through 8 by character position cut -c 1-8 report.txt # Extract bytes 1-16 cut -b 1-16 binaryish.txt # Extract multiple fields cut -d ',' -f 2,4,5 sales.csv # Preserve lines with no delimiter unchanged cut -d ':' -f 1 --only-delimited /etc/passwd
-d to set the field delimiter.-f works on fields, -c on characters, and -b on bytes.