UNIX-- 1) Consider the address book below: $ cat addr Xiao Li, lxiao@unc.edu, 67
ID: 3911712 • Letter: U
Question
UNIX--
1) 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.
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)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
TIA!!
Explanation / Answer
Answer:
Here, I have following script as shown below
#!/bin/bash
sort -k 3 addr.txt > addr1.txt
# this -k to add many fields to sort.
#and then it will sort based on 3rd row and so result loaded into addr1.txt
sed -n '1p'|awk '{print $1,$2,$3}'
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.