unix commands -- Sort the addr file by phone number and print lines 1 thru 3. Pr
ID: 3828679 • Letter: U
Question
unix commands --
Sort the addr file by phone number and print lines 1 thru 3.
Print the lines that end with valid zip code
Print the lines that end with invalid zip code
Add the string “School Email” next to all email addresses ending with “.edu”
Provide the sed command to get rid of the lines with private email addresses
Provide the command to print the rows that use imap number.
Provide a command to print only the first name, last name and email address of the person.
Print the names, phone number, and zip in a tabular manner
Print the Last Name, First Name, Email Address and zip in a tabular format. Include the header identifying each field.
addr file
Addr (Column 1 – LastName, Column2: First name, Column3: email address, Column4: phone number, Column5: zip code)
Hilton,Tom,thilton.yahoo.com,85281345,543781,imap987648790
Potter,Harry,hpotter@hogworts.edu,853645555,875234
Granger,Herminone,hgranger@hogworts.edu,9856017638,334567
Moe,Elizi,emoe@yahoo.com,3892000109,345678
Ta,Ma,mata@asu.edu,6747829191,85281
Five,Jackson,jfive@asu.edu,7839209871,78339
Bean,Sean,sbean@asu.edu,56783908156,78648
Turner,Sophie,sturner@asu.edu,6784937689,9873329
thanks!
Explanation / Answer
1. sort -k3 -t, addr.txt
2. grep '.{6,}' addr.txt
3. grep -x '.{1,5}' addr.txt
4. egrep '.edu' addr.txt
5. egrep ‘.com/d’ addr.txt
6. egrep 'imap+' addr.txt | awk {'print$6'}
7. cut -d: -f 2,1,3 addr.txt
8. awk -F',' '{printf "%-30s|%-30s|%-20s ",$1,$2,$4,$5}' addr.txt
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.