0
0
Linux CLIscripting~10 mins

cut (extract columns) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to extract the first column from a file named data.txt using cut.

Linux CLI
cut -d',' -f[1] data.txt
Drag options to blanks, or click blank then click option'
A1
Ball
C2
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the field number, which is invalid.
Forgetting to specify the delimiter with -d.
2fill in blank
medium

Complete the code to extract columns 2 and 4 separated by a comma from data.csv.

Linux CLI
cut -d',' -f[1] data.csv
Drag options to blanks, or click blank then click option'
A2,4
B1,3
C4,2
D2-4
Attempts:
3 left
💡 Hint
Common Mistakes
Using a range like 2-4 which extracts columns 2, 3, and 4 instead of just 2 and 4.
Swapping the order of columns unintentionally.
3fill in blank
hard

Fix the error in the code to extract the third column from file.txt where columns are separated by tabs.

Linux CLI
cut -d[1] -f3 file.txt
Drag options to blanks, or click blank then click option'
A,
B$'\t'
Ctab
Dspace
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma instead of tab as delimiter.
Writing 'tab' as a string instead of the escape sequence.
4fill in blank
hard

Complete the code to extract columns 1 and 3 from records.txt where fields are separated by a colon.

Linux CLI
cut -d: -f[1] records.txt
Drag options to blanks, or click blank then click option'
A:
B1,3
C2,4
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma as delimiter instead of colon.
Selecting wrong fields like 2,4 instead of 1,3.
5fill in blank
hard

Fill all three blanks to extract columns 2 and 5 from data.tsv where fields are tab-separated.

Linux CLI
cut -d[1] -f[2] data.tsv > [3]
Drag options to blanks, or click blank then click option'
A$'\t'
B2,5
Coutput.txt
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma as delimiter instead of tab.
Forgetting to redirect output to a file.
Selecting wrong columns.