Recall & Review
beginner
What does the
cut command do in bash scripting?The
cut command extracts sections from each line of input, usually by specifying a delimiter and fields or by character positions.Click to reveal answer
beginner
How do you use
paste in bash scripting?The
paste command merges lines of files horizontally, joining corresponding lines from each file separated by a tab or a specified delimiter.Click to reveal answer
beginner
Example: What does
cut -d',' -f2 file.txt do?It extracts the second field from each line of
file.txt, assuming fields are separated by commas.Click to reveal answer
intermediate
How can you combine
cut and paste to rearrange columns?You can use
cut to extract columns from files and then use paste to join those columns side by side in a new order.Click to reveal answer
beginner
What option in
cut lets you select characters instead of fields?The
-c option lets you select specific character positions from each line.Click to reveal answer
Which
cut option extracts fields based on a delimiter?✗ Incorrect
The
-f option extracts fields based on a delimiter (set with -d or default tab).What does the
paste command do?✗ Incorrect
paste joins lines from files side by side, separated by tabs or a specified delimiter.How do you extract the first 5 characters of each line using
cut?✗ Incorrect
The
-c option selects character positions, so cut -c1-5 extracts characters 1 to 5.Which command sequence joins the second column of file1.txt with the first column of file2.txt?
✗ Incorrect
Using process substitution
<(cut -f1 file2.txt) extracts the first column from file2.txt, then paste joins it with the second column from file1.txt.What delimiter does
paste use by default?✗ Incorrect
paste uses a tab character as the default delimiter between joined lines.Explain how you would extract specific columns from a CSV file and then combine them in a new order using bash commands.
Think about using cut with -d and -f, then paste to join columns side by side.
You got /5 concepts.
Describe the difference between selecting fields and selecting characters with the cut command.
Fields depend on delimiters; characters are positions in the line.
You got /5 concepts.