I have n files (for ex:64 files) with one similar column. Is it possible to combine them all based on that column ?
file1
ax100 20 30 40
ax200 22 33 44
file2
ax100 10 20 40
ax200 12 13 44
file2
ax100 0 0 4
ax200 2 3 4
output
ax100 20 30 40 10 20 40 0 0 4
ax200 22 33 44 12 13 44 2 3 4
pludi
2
See the man page for the man join (POSIX) command.
I checked it already. But it was referring to 2 files only. In my case I have multiple files.
Try:
temp=$(cat file1);for i in file2 file3; do temp=$(echo $temp | join -j1 - $i); done; echo $temp
but the problem is that i have many files (73 files).
Rename one file to something starting different than others, file names example:
a
b1
b2
b3
b4
...
Then run my code like this:
temp=$(cat a);for i in b*; do temp=$(echo $temp | join -j1 - $i); done; echo $temp
system
7
cat file1 > outputfile
for file in `ls files2to73 | xargs`
do
cut -d" " -f2,3,4 $file > temp
paste -d" " outputfile temp > outputfile
done
awk '{i=$1;sub(i,x);A=A$0} FILENAME==ARGV[ARGC-1]{print i A}' file*
2 Likes
not working for me @scrutinizer
---------- Post updated at 03:46 AM ---------- Previous update was at 03:31 AM ----------
working fine i think
---------- Post updated at 04:32 AM ---------- Previous update was at 03:46 AM ----------
Is it possible to introduce tab spacing in the output ?
awk '{i=$1;$1=x;A=A$0} FILENAME==ARGV[ARGC-1]{print i A}' OFS='\t' file*