Bash Shell Scripting for file handling

Add two single column file side by side

  • Of same length
 
awk 'NR==FNR{_[NR]=$0;next}{print $1,$2,_[FNR]}' file2 file1 

  • Of different length
awk 'NR==FNR { a[c=FNR]=$0; next }{ printf "%-8s\t%s\n", a[FNR], $0 }
END { for(i=FNR+1;i<=c;i++) print a[i] }' file2 file1


Cut n-th column of a file to separate file

 
awk < infile '{print $n}' > outfile

Comments

Popular posts from this blog

VMD High Resolution Image and Movie

Inset Plot in GRACE (Xmgrace)