awk - Combine two columns from different files into one table side-by-side using bash script -
i have 2 files,from trying extract third column each file , combine them together.how combine them 1 table side-by-side?
file1="maize.txt" file2="wheat.txt" awk -f '{print $3}' file1 awk -f '{print $3}' file2 "wheat.txt" chr - b73_chr10 b73-chr10 0 150189435 chr - w22_chr7 w22-chr7 0 176764762 chr - w22_chr8 w22-chr8 0 175793759 "maize.txt" chr - w22_chr9 w22-chr9 0 156750706 chr - w22_chr10 w22-chr10 0 150189435 chr - w22_chr6 w22-chr6 0 169174353 output : b73_chr10 w22_chr9 w22_chr7 w22_chr10 w22_chr8 w22_chr6
using awk can do:
awk -v ofs='\t' 'fnr==nr{a[fnr]=$3; next} {print a[fnr], $3}' wheat.txt maize.txt b73_chr10 w22_chr9 w22_chr7 w22_chr10 w22_chr8 w22_chr6
Comments
Post a Comment