0
0
Bash Scriptingscripting~10 mins

cut and paste 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 extract the first field from a file using cut.

Bash Scripting
cut -d',' -f[1] data.csv
Drag options to blanks, or click blank then click option'
A1
B2
C3
D4
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as field number (fields start at 1).
Using wrong delimiter.
2fill in blank
medium

Complete the code to paste two files side by side separated by a comma.

Bash Scripting
paste -d[1] file1.txt file2.txt
Drag options to blanks, or click blank then click option'
A:
B,
C|
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using colon or pipe instead of comma.
Forgetting the -d option.
3fill in blank
hard

Fix the error in the command to extract the second field separated by colon.

Bash Scripting
cut -d[1] -f2 /etc/passwd
Drag options to blanks, or click blank then click option'
A;
B,
C:
D|
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma or semicolon as delimiter.
Omitting the -d option.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Bash Scripting
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using word instead of len(word) for length.
Using < instead of > for filtering.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than zero.

Bash Scripting
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using k instead of k.upper() for keys.
Using < instead of > for filtering values.