EUREKA!!
Ok just to clarify, I apologise grail for not copying and pasting your last command. I just tried this:
Code:
awk '$10 < -1000 && $10 > -3000{print > "filt_" FILENAME}' Int_DU145withTannopeaks.txt
and still got the following error:
Code:
awk: syntax error at source line 1
context is
$10 < -1000 && $10 > -3000{print > "filt_" >>> FILENAME <<< }
awk: illegal statement at source line 1
I don't understand though why it works for you grail and not me. I'm probably doing something wrong still.
It seems that your suggestion ntubski works. When I tried using the command with the parentheses added, it worked fine for one single file. I then took it further and tried it on multiple files in my directory and this also worked great.
So for future readers, to clarify, you can filter a text file for a range of negative numbers in a specific column (column 10 in this case) on multiple files with this without for loops etc:
Code:
awk '$10 < -1000 && $10 > -3000{print > ("filt_" FILENAME)}' *.txt
or I still maintain that the original edit with the for loop does actually work too but perhaps with caveats:
Code:
for foo in $(ls -1 *.txt); do cat $foo | awk '{ if ($10 < -1000 && $10 >= -3000) print $0;}' >> filtered_$foo ; done