Unix script, please help I am lost. f. Double quotes in the file must be remove.
ID: 3705906 • Letter: U
Question
Unix script, please help I am lost.
f. Double quotes in the file must be remove. The output must be the same file (i.e. filename must not change)
g. Suppose you don’t know how many fields are in a line, but you wish to use “cut” to extract the last field.
h. Now use the above technique to count the total number of Family primary plans
MemberLastName MemberSSN DOB_Month DOB_Day DOB_Year Address1 Address2 City State ZipCode AreaCode HomePhone Email Deduction Method Customer-Defined Relationship Primary FamilyID UniqueID Plan_Type ProductID Johnson 157-35-9734 3 22 1991 8347 Garfield St. Phoenix AZ 85005 626 2546314 Isajoh_email.com Employer Payroll Deduction P Y 887503 157862453 Individual Delgado 374-82-3459 12 13 1986 1852 Greenfield Ave. Tempe AZ 85001 626 9541254 Dendan_email.com Employer Payroll Deduction P Y 345201 713245694 Individual Anderson 621-75-7319 7 4 1992 7254 Bushey Dr. Scottsdale AZ 85257 626 7541208 ronand_email.com Employer sponsored P Y 102457 954231864 Individual Gonzales 942-16-3495 1 11 1983 9213 Circle St. Tempe AZ 85001 626 3036425 julgon_email.com Employer Payroll Deduction P Y 245873 321509554 Family Brown 642-72-1975 10 7 1982 9745 Trenton St. Phoenix AZ 85005 626 3021576 kribro_email.com Employer sponsored S N 245873 985214765 Family Mork 123456789 2 1 1994 505 W BASELINE RD 2003 Tempe AZ 85283 602 4325110 amork1_asu.edu Employer Payroll Deduction P Y Individual PAP Doe 987654321 7 24 1980 1234 FAKE LANE RD Phoenix AZ 85254 602 4023214 johnwaynedoe_email.com Employer Sponsored P Y Individual PA Girl 456789123 9 12 1990 6732 LAKESIDE RD Tucson AZ 85641 480 9807632 aliceanngirl_email.com Employer Payroll Deduction P Y Individual PA Guy 321789654 1 30 1974 1095 MOUNTAIN RD Tempe AZ 85283 602 7915402 bobchrisguy_email.com Employer Payroll Deduction P Y F123 L111 Family PAPExplanation / Answer
Answer f:
cat <file_name> | sed 's/"//g' >> <new_file_name>
mv <new_file_name> <file_name>
First command will replace all double quotes with null using sed command and new data will be written in <new_file_name> after that we run our second mv command and change new_file_name to it's oroginal file name.
--------------------------------------------------------------------------------------------------------------------
Answer g:
cat <file_name> | rev | cut -d, -f1 | rev
Here first we extract all data from file and reverse it from right to left. Now last field will become first field, assuming that delimiter is single comma (,) in file we cut -f1 ( first column ) and again reverse it in order to find original value.
---------------------------------------------------------------------------------------------------------------
Answer h:
wc -l <file_name>
We can use above simple command to count all records ( rows) in file. This command will include header in count as well so correct answer will be count - 1.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.