Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as the field number, which is invalid.
Using the wrong delimiter.
✗ Incorrect
The first column in a CSV file is selected with -f1 using cut and delimiter ','.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail -n +1 which includes the header.
Using head instead of tail.
✗ Incorrect
tail -n +2 skips the first line (header) and counts the rest.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Printing $1 instead of $2.
Forgetting to set the field separator.
✗ Incorrect
To print the second column, use print $2 with awk and comma delimiter.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up column numbers.
Using wrong field separators.
✗ Incorrect
Column 1 ($1) is the key and column 3 ($3) is the value separated by a colon.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column numbers in condition or print.
Forgetting to set the field separator.
✗ Incorrect
Filter rows where $2 > 50 and print $1 and $2 separated by a comma.