What are you hoping to accomplish with NR==1
in your awk action? That means your action will only execute for the first line of your input. So regardless of how many lines of input you feed to awk, that action will (a) only run once, and (b) may not output anything, unless the first line happens to match something
or something2
.
I'm not completely clear on what you're trying to do, but maybe this will help:
gawk '
NR==1 {print}
$1 == "something" || $1 == "something2" {print FILENAME, $1,$2,$4}
' file1.csv file2.csv file3.csv > test1.txt
This will run for every line, instead of just the first one. If the first field is something
or something2
, it will print out fields 1, 2, and 4.
UPDATE: I've modified this to print the first line of the input.