Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Having trouble devising a script to do the requested below (please do in UNIX ba

ID: 3735110 • Letter: H

Question

Having trouble devising a script to do the requested below (please do in UNIX bash or sh NOT java)

Consider the file named data1 as shown below:

lxiao,lxiao@unc.edu,6705462234,Jackson,NC,764

wnatkin,wnatkin@vcu.edu,8044344528,Salem,VA,22345

emoe,emoe@ncsu.edu,5208534566,Tempe,AZ,85282

mta,mta@yahoo.com,4345667345,Austin,TX,91030

dcheng,dcheng@asu.edu,5203456789,Matitsi,WY,4587

jfive,jfive@ncsu.edu,5206564573,Kyenta, AZ,85483

sadi1,sadi1@asu.edu,6578904566,Wyo,WS,67854

The format is:

UserID,UserID@Email,PhoneNumber,City,State,ZipCode

Write a script named Lab4B.1.sh to print the data in the following tab delimited format:

UserID    PhoneNumber    State    ZipCode

Explanation / Answer

#replacing each and every ',' with ' '
sed -i 's/,/ /g' input_file.txt
#reading line by line
while read line
do
#moving each word of line into an array words
read -a words <<<$line
printf "%s " "${words[0]}" >>result.txt
printf "%s " "${words[2]}" >>result.txt
printf "%s " "${words[4]}" >>result.txt
printf "%s " "${words[5]}" >>result.txt
done <input_file.txt

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote