🐧 Linux / Shell Scripting
Intermediate
How do you use the cut command?
Answer
cut extracts specific columns or fields from each line of input. cut -d',' -f1,3 file.csv extracts fields 1 and 3 from a comma-delimited file. -d sets the delimiter, -f selects field numbers (1-based). cut -c1-10 file extracts characters 1 through 10. cut -d':' -f1 /etc/passwd lists all usernames. -f2- means from field 2 to end; -f-3 means from start to field 3. For files with irregular whitespace, awk is more robust. cut is POSIX-standard, fast, and great for structured data like logs with consistent delimiters.
Previous
What is the tr command used for?
Next
What is the difference between fg, bg, and & in bash?