Linux. Any help would be awesome! I feel as I am close but my commands are off a
ID: 3736316 • Letter: L
Question
Linux. Any help would be awesome! I feel as I am close but my commands are off a little.
1. Consider the file whotb below:
-bash-3.2$ cat whotb
avuong1 pts/0 2017-08-25 23:00 (10.152.100.245)
pbartakk pts/11 2017-08-25 23:29 (174.17.211.48)
zzhan281 pts/3 2017-08-25 22:52 (71.223.35.124)
jgamboa8 pts/2 2017-08-25 23:05 (71.231.248.218)
pkalungi pts/1 2017-08-25 20:12 (10.143.198.41)
ramdisk pts/20 2017-08-22 17:17 (10.106.150.87)
pbartakk pts/8 2017-08-25 22:22 (10.152.112.188)
pkalungi pts/10 2017-08-25 23:18 (10.143.198.41)
a. Display only (in order) the station #, username, and date logged in order
b. Sort the above in increasing order of the station #
c. Sort the same data in reverse order
d. Create a file called useron that contains only the usernames
e. Sort the file useron in reverse order, removing the duplicate, and saving with the same filename
f. Insert line numbers into the file useron above, starting at 100 and in increment of 10
2. Consider the address book below:
$ cat addr
Xiao Li, lxiao@unc.edu, 6705462234, Jackson, NC 764
Natkin William, wnatkin@imap28.vcu.edu, 8044344528, Richmond, VA 22345
Elizi Moe, emoe@ncsu.edu, 5208534566, Tempe, AZ 85282
Ma Ta, mta@yahoo.com, 4345667345, Austin, TX 91030
Diana Cheng, dcheng@asu.edu, 5203456789, Matitsi, WY 4587
Jackson Five, jfive@ncsu.edu, 5206564573, Kyenta, AZ 85483
Adi SrikanthReddy, sadi1@imap1.asu.edu, 6578904566, Wyo, WS 67854
a. Sort the addr file by phone number and print lines 1 thru 3.
3. Consider the address book below:
$ cat addr
Xiao Li, lxiao@unc.edu, 6705462234, Jackson, NC 764
Natkin William, wnatkin@imap28.vcu.edu, 8044344528, Richmond, VA 22345
Elizi Moe, emoe@ncsu.edu, 5208534566, Tempe, AZ 85282
Ma Ta, mta@yahoo.com, 4345667345, Austin, TX 91030
Diana Cheng, dcheng@asu.edu, 5203456789, Matitsi, WY 4587
Jackson Five, jfive@ncsu.edu, 5206564573, Kyenta, AZ 85483
Adi SrikanthReddy, sadi1@imap1.asu.edu, 6578904566, Wyo, WS 67854
a. Print the lines with imap number in the email address.
b. Print the lines that end with valid zip code
c. Print the lines that end with invalid zip code
Explanation / Answer
Hi Friend, As per the Cheg Guideline, Please post one Question per post.
I am answering Q2.
Please repost others in separate post.
The addr file contains 5 columns namely Name, email, phone number, city, and state.
Here, we can use sort command along with -n and -k flag to sort the data according to the phone number. Note that -n flag sorts data according to the numerical value and -k sorts data or field according to the given column number. Then we would use head command to display the first 3 lines.
The entire command will be as follows:
$ sort - n -k3
$ head -3 addr
Please upvote if it helped you!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.