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

Unix script commands, please help me I am lost. Any insight will be greatly appr

ID: 3705903 • Letter: U

Question

Unix script commands, please help me I am lost. Any insight will be greatly appreciated

1. Provide the commands to check each of the below requirements.

a. Check that there is no duplicated SSN. If there is/are, display how many times each is duplicated

b. Check that the area code is exactly 3 digits and the home phone number is exactly 7 digits.

c. There shall be no space in any header name, except for the header name of the first field (i.e. Effective Date). Any other space should be replaced with underscore. For example, “DOB Month” should be “DOB_Month”

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 PAP

Explanation / Answer

(a) to check that there is no duplicated SSN if there display how many times each is duplicated.

Ans: $ sort MemberSSN | uniq -c | sort -nr

uniq command checks for duplicates entries

-c counts how many times each is duplicated

-nr sort numericals and reverse the order of sort

(b) to check that the area code is exactly 3 digits and homepone number is exactly 7 digits

for areacode: $egrep Areacode '[0-9] {3}'

$echo Areacode | wc -m

for phone number :   $egrep Homephone '[0-9] {7}'

$echo Homephone | wc -m

wc -m counts characters in input

numbers within { } specifies that the record mus have exactly specifried digits like 3,7

egrep helps to dispay or find the matched contents

(c) to replace another space with underscore

1) $ rm "name: " new _name

rm helps to rename the files name with space to new name with underscore

or

2) we can use sed command

$sed -n '/ name: {:a;N/s/.* / new_name /}. p file  

  / name: : when name with space found

:a : create a lalbel "a"

N : stores next line

s/.* / new_name : replaces with new name

p :prints

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