awk - Match 2 columns in same file and exit zero if matching else proceed Unix -
i have requirement file 1 has employee details, below
empid,empname,empdaddress,empsupervisor
1234,xxx,street1,6666 2345,yyy,street2,6666 3456,uuu,street3,2345 4567,ppp,street4,9999 9999,kkk,street5,7777
now, have match empsupervisor column value empid, know if details of empsupervisor present in file1. in file sample, 2345 empsupervisor , details present in file. same 9999. 6666 emp details not present in file.
i have check if details present in file 1 check record, else exit 0 on complete searching. new unix scripting. suggestion highly appreciated. thanks
i've tried
awk 'fnr==nr {h[$1] = $11; next} ($1 in h) { print $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$15,'u' }' file2 file1 >newfile
this should work emp filename.
comm -23 <(cut -d, -f4 emp | sort -u) <(cut -d, -f1 emp | sort -u)
will give you
6666 7777
it's not clear want result , other file.
above code can rewritten using function.
p () { cut -d, -f"$1" emp | sort -u; }; comm -23 <(p 4) <(p 1)
Comments
Post a Comment