This doesn't work:
awk '
NR == FNR
{ x=$1 ; next }
{ y=$1 }
{if (x==y) print $0}
' file1.in catalog.cat > file2.res
I'm trying to make a list of catalog entries that match the line headers in file1. The program instead outputs a copy of file1. That doesn't make...
Thanks again! Could you just explain a detail to me please?
My file ended up with too many lines, so I added this command:
awk -v n=13 'NR>n{print a[NR%n]}{a[NR%n]=$0}'
to removes the last 13 lines, it works, but I would rather use
awk -v n=NR/2 'NR>n{print a[NR%n]}{a[NR%n]=$0}'
to remove...
Yo, thank you :) That's very helpful. It work and I also sorted the headers. I really augth to learn this awk thing better, it's quite impressive what it can achieve.
Hi! Basically, I have 2 text files and need to combine them into one while making a few changes. The commands I came up with were too long/slow so I figured some more familiar with awk could help me.
Basically I have these 2 files, were N~50000 :
file1.res
1 a1 a2 ... a13
2 b1 b2 ... b13
...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.