I have a large number of txt files. the format of each txt files is similar to this
200 0.2 0.1 0.5 0.4
500 0.4 0.9 0.9 0.1
I am trying to delete each line in each txt file that has the first field value greater than 400. So the above file should only contain this now:
200 0.2 0.1 0.5 0.4
Code
for file in *.txt; do
echo "$(awk '{ if ($1 < 401) print }' *.txt)" > tmp && mv tmp *.txt
done
rm -f tmp
but this doesn't work as it moves all the files to the next text file.