page

Jun 8, 2020

Adding a Column of values in a tab delimited file


Input file:

SPATA17 1   217947738
LYPLAL1 1   219383905
FAM47E  4   77192838
SHROOM3 4   77660162
SHROOM3 4   77660731
SHROOM3 4   77662248

Output file:

SPATA17 1   217947738 file1
LYPLAL1 1   219383905 file1
FAM47E  4   77192838  file1
SHROOM3 4   77660162  file1
SHROOM3 4   77660731  file1
SHROOM3 4   77662248  file1

Answer

for file in *; do awk 'BEGIN{OFS="\t"}{print $0, FILENAME}' $file; done


FILENAME is a variable in awk, it expand to current file name that awk is processing.




No comments:

Post a Comment