Hi this is for linux/unix bash script. (Terminal) The following question refers
ID: 3818044 • Letter: H
Question
Hi this is for linux/unix bash script. (Terminal)
The following question refers to a file named "cars"
This "cars" file can be created by inputting "vi cars" into the linux terminal and copying/pasting the following contents..
--------------------------------------------
plym fury 77 73 2500
chevy nova 79 60 3000
ford mustang 65 45 17000
volvo gl 78 102 9850
ford ltd 83 15 10500
Chevy nova 80 50 3500
fiat 600 65 115 450
honda accord 81 30 6000
ford thundbd 84 10 17000
toyota tercel 82 180 750
chevy impala 65 85 1550
ford bronco 83 25 9525
--------------------------------------------
Question :
1.
a) Sort the cars by price. Pipe the output of the sed in the previous question into a sort to do this, and do not forget to sort numerically on the fifth field.
b) Finally, display the output of question 2 in uppercase. Pipe the output of the sort into a tr command.
Explanation / Answer
1 a)
Though I don't know previous part but you can just put part in bold after your sed command
sed -n '/[0-9]{5}$/!p' cars | sort -n -k 5
This will sort numerically (-n) on 5 th field (-k 5)
b) sed -n '/[0-9]{5}$/!p' cars | sort -n -k 5 | tr "[a-z]" "[A-Z]"
This last part is converting any char from a to z to upper case.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.