0
0
Bash Scriptingscripting~10 mins

Processing CSV files in Bash Scripting - Interactive Code Practice

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

Complete the code to print the first column of a CSV file named data.csv.

Bash Scripting
cut -d',' -f[1] data.csv
Drag options to blanks, or click blank then click option'
A2
B3
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the field number, which is invalid.
Using the wrong delimiter.
2fill in blank
medium

Complete the code to count the number of lines in a CSV file named data.csv excluding the header.

Bash Scripting
tail -n +[1] data.csv | wc -l
Drag options to blanks, or click blank then click option'
A2
B1
C0
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail -n +1 which includes the header.
Using head instead of tail.
3fill in blank
hard

Fix the error in the code to print the second column of data.csv using awk.

Bash Scripting
awk -F',' '[1]' data.csv
Drag options to blanks, or click blank then click option'
Aprint $2
Bprint $0
Cprint $3
Dprint $1
Attempts:
3 left
💡 Hint
Common Mistakes
Printing $1 instead of $2.
Forgetting to set the field separator.
4fill in blank
hard

Fill both blanks to create a dictionary-like output of column 1 as key and column 3 as value from data.csv using awk.

Bash Scripting
awk -F',' '{print [1] ":" [2]' data.csv
Drag options to blanks, or click blank then click option'
A$1
B$2
C$3
D$4
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column numbers.
Using wrong field separators.
5fill in blank
hard

Fill all three blanks to filter rows where the value in column 2 is greater than 50 and print columns 1 and 2 separated by a comma.

Bash Scripting
awk -F',' '[1] > [2] {print [3] "," $2}' data.csv
Drag options to blanks, or click blank then click option'
A$2
B50
C$1
D$3
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column numbers in condition or print.
Forgetting to set the field separator.