Search Results

Search: Posts Made By: Shyam_84
1,969
Posted By Shyam_84
yes this works , appends properly awk -F,...
yes this works , appends properly

awk -F, 'FNR==NR{a[$1]=$7;next} {print (($1 in a) ? $0","a[$1] : $0",NA");}' file2 file1 > tmp && mv tmp file1

thanks all

[root@oc6120651657 shyam]# awk...
1,969
Posted By Shyam_84
ok file1.txt XX,ZZ,XC,EE,RR,BB ...
ok

file1.txt
XX,ZZ,XC,EE,RR,BB
XC,CF,FG,RG,GH,GH

File2.txt

DF,GH,MH,FR,FG,GH,NOTOK
XX,NM,XC,EE,RT,BB,OK

Result

Day1

XX,ZZ,XC,EE,RR,BB,OK -- > since xx in both file1,file2...
1,969
Posted By Shyam_84
okay first command works if i want to add...
okay first command works

if i want to add NA

XX,ZZ,XC,EE,RR,BB,OK
XC,CF,FG,RG,GH,GH,NA

file1 is base template , is that possible to print NA if the first column is not found in file2 as...
1,969
Posted By Shyam_84
yes below is idea grep the first column in file1...
yes below is idea grep the first column in file1 and compare with
first column in file2 and awk the 7 th column value and print result

for n in `cat /tmp/file1.txt |awk -F "," '{print $1}'`...
1,969
Posted By Shyam_84
Comparing columns in 2 text files
Hi

i have 2 files

file1.txt

XX,ZZ,XC,EE,RR,BB
XC,CF,FG,RG,GH,GH

File2.txt
DF,GH,MH,FR,FG,GH,NOTOK
XX,ZZ,XC,EE,RR,BB,OK


result

XX,ZZ,XC,EE,RR,BB OK

look for column1 ,...
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 09:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy