unsortedNames.txt: N D Street Faye King Lenny R Graph I M Board Mark R Board Sal
ID: 3890726 • Letter: U
Question
unsortedNames.txt:
N D Street
Faye King
Lenny R Graph
I M Board
Mark R Board
Sal Ed Barr
Grey Wire
Holly Graph
Perry Scope
Bob L Head
Joe King
Holly Wood
Ava Kashun
Jean E Us
Mac A Ronee
E Racer
Hammond Ecks
B B Gunn
Cooke King
Tuck King
N D Carr
Otto Graph
Dee Boat
Anita Goodgrade
Explanation / Answer
Below is the command when run in a prompt will give you output desired (awk and sort both is been used)
awk '{print $NF}' unsortedNames.txt | sort -u >lname.txt;while read line; do grep -w $line unsorted.txt; done<lname.txt
#Above awk script will sort the last column and redirects it to lname.txt file, which in turn is run on while loop to print the sorted file based on the last name on the prompt.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.