In: Computer Science
Do not use awk.
Using the fixed length field file called famous.dat,
make a one-line Unix command - using pipe(s) - to
display an alphabetical list of the last and first names
in upper case of the last 8 people in the file. Hint:
Names are in columns 6 through 35. Output is this..
DARWIN
CHARLES
EINSTEIN
ALBERT
GALILEO
GALILELI
GOLDMAN
EMMA
LOVELACE
ADA
MANDELA
NELSON
PARKS
ROSA
RUSSELL BERTRAND
Hint: famous.dat uses space(s) to separate the fields
Pipes:
pipes are the components in unix that are used to carry on the output on one command to the next one.
tail:
tail is used to print the specified number of rows from last of the file.
Cut:
The cut command is used to perform vertical selection of columns from the file or output that is passed on to it.
Answer:
tail -8 famous.dat | cut -d " " -f 6,35 | tr '[:lower:]' '[:upper:]'
Explaination:
In the above command,the tail command is used to select the last 8 rows from the file famous.dat
The output is passed on to the next command using pipe
The cut is used to select the first and last name fields using delimiter as spaces between the fields.
This output is passed on to the next command using pipe.
This contains the first and last names of the people.
The tr '[:lower:]' '[:upper:]' command is used to convert the data to Upper case format.
This output is then passed on to be displayed through the terminal.
The screenshot of execution is attached below for the reference.
Screenshot:
The data file that is used to perform operations is shown.
Output: