Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

create the grocery.list as apples, parsley, ginger, vanilla yogurt, ice CUT 1) W

ID: 3813350 • Letter: C

Question

create the grocery.list as apples, parsley, ginger, vanilla yogurt, ice CUT 1) We want to print out only the first character of each line.

Using the "cut" command:

q1: What option (e.g. -[letter]) would you use to select by character?

q2: What value would you use with the option from q1?

2) We want to print out first & third characters of each line.

Using the "cut" command:

q1: What option (e.g. -[letter]) would you use to select by character?

q2: What value would you use with the option from q1?

3) Using the "cut" command, what happens if you use the option "-c-"? SPLIT

4) Make a new directory, "split_files" and copy the grocery.list into it.

5) We want to split our grocery list into multiple files, each file containing exactly two (2) lines from the original list. q1: What option would you use to select by line? q2: What value would you use?

6) Using the split command, what happens if you use the "-n25" option on the grocery.list? SORT

7) Make a copy of the original grocery.list, called numbered_grocery.list

8) Using vi, insert item numbers before each grocery item. For example, apples should become 1 apples

q1: What command would we use to sort the numbered grocery.list alphabetically?

q2: What command would we use to sort the numbered grocery.list numerically?

q3: What command would we use to sort the numbered grocery.list randomly? UNIQ

9) Create a new grocery.list (call it dup_grocery.list) by concatenating grocery.list with itself.

10) Run the "uniq" command against dup_grocery.list.

q1: Do you think the output will be a unique list or the entire duplicated list?

11) What full command would you use to print the unique lines along with the number of times each appears in dup_grocery.list?

Explanation / Answer

q2: 1 -> value to be passed with option

2) cut -c1,3 grocery.list

3) The entire line would get printed when you don’t specify a number before or after the ‘-‘

4) mkdir split_files

  cp grocery.list split_files

5) q1: -l

q2: 2 -> value to be used with option

split -l 2 grocery.list segment --> segment is the prefix, the name we wish to give the small output files.

6) split into 25 files(chunks) based on size of input.

7) cp grocery.list numbered_grocery.list

8) vi grocery.list

-- write the line numbers in the editor and press :wq to save and exit.

q1: sort grocery.list

q2: sort -n grocery.list

q3: sort -R grocery.list

9) cat grocery.list >> dup_grocery.list

10) uniq dup_grocery.list

11) uniq -c dup_grocery.list