25 cut Command Examples

1. Extract first column from file

$ cut -f1 data.txt
Output: Column1 values

2. Extract multiple columns (1st and3rd)

$ cut -f1,3 data.txt
Output: Column1 Column3 values

3. Extract range of columns (2nd to4th)

$ cut -f2-4 data.txt
Output: Column2 Column3 Column4 values

4. Use custom delimiter (comma)

$ cut -d',' -f1,2 csvfile.csv
Output: First,Second values

5. Extract characters by position (1st-5th)

$ cut -c1-5 file.txt
Output: First5 characters

6. Extract specific characters (1st,3rd,5th)

$ cut -c1,3,5 file.txt
Output:1st,3rd,5th characters

7. Extract bytes instead of characters

$ cut -b1-10 file.txt
Output: First10 bytes

8. Complement selection (everything except1st column)

$ cut -f1 --complement data.txt
Output: All columns except first

9. Extract from piped input

$ echo "apple,banana,cherry" | cut -d',' -f2
Output: banana

10. Extract fields with space delimiter

$ cut -d' ' -f2-3 spacedfile.txt
Output: Second and third fields

25. Extract with tab delimiter (default)

$ cut -f2-3 tabfile.txt
Output: Second and third tab-separated fields