Recall & Review
beginner
What does the
cut command do in Linux?The
cut command extracts sections from each line of input, usually columns or fields, based on delimiters or character positions.Click to reveal answer
beginner
How do you extract the first 5 characters of each line using
cut?Use
cut -c 1-5 filename to get characters 1 through 5 from each line of the file.Click to reveal answer
beginner
What option do you use with
cut to specify a delimiter other than the default tab?Use
-d followed by the delimiter character, for example cut -d ',' -f 2 file.csv to extract the second field separated by commas.Click to reveal answer
beginner
How do you extract the 2nd and 4th fields from a comma-separated file using
cut?Use
cut -d ',' -f 2,4 filename to get the 2nd and 4th fields separated by commas.Click to reveal answer
beginner
What happens if you use
cut -f 1-3 without specifying a delimiter?By default,
cut uses the tab character as the delimiter. So it extracts fields 1 to 3 separated by tabs.Click to reveal answer
Which
cut option extracts characters by position?✗ Incorrect
The
-c option extracts characters by position.How do you specify a comma as the delimiter in
cut?✗ Incorrect
Use
-d , to specify a comma delimiter.What does
cut -f 2-4 do by default?✗ Incorrect
By default,
cut uses tab as delimiter and extracts fields 2 to 4.Which command extracts the first 3 characters of each line?
✗ Incorrect
cut -c 1-3 extracts characters 1 to 3.What does the
-s option do in cut?✗ Incorrect
The
-s option suppresses lines that do not contain the delimiter.Explain how to use
cut to extract specific fields from a comma-separated file.Think about how to tell cut what separates the fields and which fields to get.
You got /5 concepts.
Describe the difference between extracting characters and extracting fields with
cut.Consider what you want to cut: fixed positions or separated parts.
You got /4 concepts.