Question

from the file "classfile.dat" bellow do the following commands : a. Display the contents of the...

from the file "classfile.dat" bellow do the following commands :

a. Display the contents of the file sorted by last name. Ignore leading white space

. b. Display lines, with line numbers, for Computer Science majors.

c. Display lines for students whose e-mail addresses end with .edu.

d. Display all lines but show only the last name and GPA, sorted by GPA.

2. Search your home directory and all sub-directories, and display pathnames of all C++ program files. Terminate your command line with 2> /dev/null in order to ignore error messages.

6. Write a command to output the inode/filename pairs for all the files in /export/home/public/rajni/esit200, sorted by inode number.

=====================================================

classfile.dat:

John Doe ECE 3.54 doe@jd.home.org 111.222.3333
James Davis ECE 3.71 davis@jd.work.org 111.222.1111
Al Davis CS 2.63 davis@a.laers.org 111.222.2222
Ahmad Rashid MBA 3.74 ahmad@mba.org 111.222.4444
Sam Chu ECE 3.68 chu@sam.ab.com 111.222.5555
Arun Roy SS 3.06 roy@ss.arts.edu 111.222.8888
Rick Marsh CS 2.34 marsh@a.b.org 111.222.6666
James Adam CS 2.77 jadam@a.b.org 111.222.7777
Art Pohm ECE 4.00 pohm@ap.a.org 111.222.9999
John Clark ECE 2.68 clark@xyz.ab.com 111.111.5555
Nabeel Ali EE 3.56 ali@ee.eng.edu 111.111.8888
Tom Nelson ECE 3.81 nelson@tn.abc.org 111.111.6666
Pat King SS 2.77 king@pk.xyz.org 111.111.7777
Jake Zulu CS 3.00 zulu@jz.sa.org 111.111.9999
John Lee EE 2.64 jlee@j.lee.com 111.111.2222
Sunil Raj ECE 3.36 raj@sr.cs.edu 111.111.3333
Charles Right EECS 3.31 right@cr.abc.edu 111.111.4444
Diane Rover ECE 3.87 rover@dr.xyz.edu 111.111.5555
Aziz Inan EECS 3.75 ainan@ai.aedubc.org 111.111.1111
Lu John CS 3.06 lu.john@xyz.org 111.333.1111
Lee Chow EE 3.74 chow@lc.www.ord 111.333.2222
Adam Giles SS 2.54 giles@cric.org 111.333.3333
Andy John EECS 3.98 john@aj.ece.edu 111.333.4444

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a. Display the contents of the file sorted by last name. Ignore leading white space

cat classfile.dat|sort -u -k2

****-u for field wise sort by sort command, and k2 means 2nd field.

b. Display lines, with line numbers, for Computer Science majors.

cat classfile.dat|grep -nw "CS

****grep is for search, -n for line numbers,w for word wise search

c. Display lines for students whose e-mail addresses end with .edu.

cat classfile.dat|grep "\.edu"

****grep for search, and \ is for .

d. Display all lines but show only the last name and GPA, sorted by GPA.

cat classfile.dat|sort -u -k4|tr -s " "|cut -d " " -f 2,4

****tr is used for squeeze characters and cut is used for extract field wise. -d in cut is for delimeter.

2. Search your home directory and all sub-directories, and display pathnames of all C++ program files. Terminate your command line with 2> /dev/null in order to ignore error messages.

find /root -name "*.cpp" 2>/dev/null

****find command is used for search files with path

6. Write a command to output the inode/filename pairs for all the files in /export/home/public/rajni/esit200, sorted by inode number.

ls -i /export/home/public/rajni/esit200|sort -u -k1

****ls -i displays filename with inode number.

Add a comment
Know the answer?
Add Answer to:
from the file "classfile.dat" bellow do the following commands : a. Display the contents of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT