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

mountainList.txt: Unix: 1) use sed to list the line beginning with white space i

ID: 3871302 • Letter: M

Question

mountainList.txt:

Unix:

1) use sed to list the line beginning with white space in "mountainList.txt".

2) Use sed to delete the lines where the mountains are only at Union County
in "mountainList.txt".

3) Use sed to remove the middle three fields in each line of "mountainList.txt".
Hint: Think about the meaning of regex '[^,]'

4) Use sed to insert a new line “Table: Eleven highest mountains in Georgia”
at the beginning of "mountainList.txt".

5) Use sort to print out the sorted lines in alphabetical order according to the
names of mountains.

6) Use sort to print out the sorted lines in descending order according to the
height of mountains.

7) Now can you write a command to finish task 3) using sed with backreference?

Brasstown Bald, (summit),4784,feet, Union County Rabun Bald, (summit),4696,feet,Rabun County Dick's Knob, (summit),4620,feet,Rabun County Hightower Bald, (summit),4568,feet,Towns County Wolfpen Ridge, (ridge high point),4561,feet,Towns and Union Counties Blood Mountain, (summit),4458,feet,Union County Tray Mountain, (summit), 4430,feet,Towns County Grassy Ridge, (ridge high point),4420,feet, Rabun County Slaughter Mountain, (summit),4338,feet, Union County Double Spring Knob, (summit),4280,feet,Rabun County Coosa Bald, (summit),4280,feet,Union County

Explanation / Answer

1)sed -n '/^[[:space:]]/p' mountainLst.txt #"^" indicates beginning, [[:space:]] indicates whitespace, p is to print.

2)sed -i.bak '/Union County/d' mountainLst.txt #Search for the pattern and use "d" optio, can create backup with i.bak command

3)sed 's/,.*,/,/g' mountainLst.txt #It will delete all the 3 middle fields,

4)sed -i.bak '1s/^/Table: Eleven highest mountains in Georgia/' mountainLst.txt #It will insert in the line 1 with the backup. Substitute with "^" in the beginning with the text

According to the Chegg Forum rules, We can answer only 4 sub topic questions not more than that.

Thanks for asking the question, Please let me know if you have any queries will be glad to help