I have nearly 1000 data files in a single directory with extension .trm1 and .trm2 and both the extension files contain two column data (such as data1 and data2). Anyway, I do not want to disturb data1 of both the extension files. Now i want to choose column-2(data2) randomly
of any .trm2 files and try to add the same to the column-2(data2) of any of the .trm1 extension files and the output should be saved in .trm1trm2(where column1(data1) should contain what is already there in .ext1 file and column2(data2) should contain the added data.The same thing i want to do for all the files with extension .trm1. My data sample and code is given below:Thanks in advance.
file1.trm1 file4.trm2 outputfile.trm1trm2
data1 data2 data1 data2 data1 data2
20 2.5 20 3.9 20 6.4
40 1.5 12 3.4 40 4.9
10 1.2 24 1.5 10 2.7
34 1.1 32 6.9 34 8.0
#!/bin/sh
for file in /home/lijun/datadir/*.trm2
do
awk '{print $2}' $file
for file1 in /home/lijun/datadir/*.trm1
do
awk '{print $2}' $file1
sum =
Aucun commentaire:
Enregistrer un commentaire