I would like to print the output beginning with a header from a seperate file like this:
awk 'BEGIN{FS="_";print ((getline < "header.txt")>0)} { if (! ($0 ~ /EL/ ) print }" input.txt
What am i doing wrong?
I would like to print the output beginning with a header from a seperate file like this:
awk 'BEGIN{FS="_";print ((getline < "header.txt")>0)} { if (! ($0 ~ /EL/ ) print }" input.txt
What am i doing wrong?
Try:
awk 'NR==FNR{print;next}!/EL/' header.txt input.txt
Thanks! Just curious, how would the code look like with text from a sperate second file at the end/bottom of the output-file?
You appear to be trying to print the return value of getline, but it returns a status, not the record read.
getline sets $0 if you don't specify a variable, so you could have:
awk 'BEGIN{FS="_"; if ((getline < "header.txt") > 0) {print}} { if (! ($0 ~ /EL/ ) print }" input.txt
awk 'NR==FNR && !/EL/;NR!=FNR' input.txt end.txt