I am having two set of files with different number of columns and rows.
A set of files have only single row with 20 columns.
B set of files have 1000s of rows with 5 columns.
both set contains equal number of files.
I want to save all the 20 columns of A in variables one by one and then compare it with 5th column of set B files. If it matches....it should print the 4th column of set B files.
I have tried ur code. It works well
But it shows output only for a single A file and its corresponding single B file.
Now, I need to run it for multiple files and save their data into new file.
I tried the following code, but it doesnt work:(
f
name=list1
exec<$fname
while read line
do
f2name=list2
exec<$f2name
while read line2
do
awk ' NR==1{a=$1; next} $2=="BBM" && $5==a {print $4}' $line $line2> $line"456"
done
done
thanks for the help!!!!
---------- Post updated at 07:40 AM ---------- Previous update was at 06:04 AM ----------
Hi ygemici,
code given by you also works for single A file and single B file.
the output shown is :
RGF
HGD
ALA
ALA
ALA
ALA
ALA
ALA
ALA
ALA
ALA
ALA
ALA
Although I need to display only RGF
Kindly help me to work with multiple files at a time.
126 ALA 124 VAL 5.242442
126 ALA 125 GLY 3.839224
126 ALA 126 ALA 0.000000
126 ALA 127 LEU 3.789894
126 ALA 128 THR 5.824391
126 ALA 129 LYS 8.606871
126 ALA 130 VAL 10.355069
126 ALA 131 TYR 9.790689
126 ALA 132 SER 11.737067
I want to compare 1st column of list1 files with 5th column of list2 files,
if it is same && the 2nd column of list2 files are "ALA", it must print 4th column of list2 files.
I used the below code:
fname=list1
exec<$fname
while read line1
do
fname2=membdistlist
exec<$fname2
while read line2
do
awk 'NR==1{s=$1; next} $2=="ALA" && $5==s {print $4} ' $line1 $line2
done
done
Output: It is printing "ALA" multiple number of times, which is wrong output.
Whereas, the command:
Which is showing single file from list 1 and single file from list2 is showing the correct output.
Can any one help in accessing this code for multiple files ????
Thanx in advance