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.
echo $( some_command )
materially different from just writingsome_command
– Chris Davies May 03 '22 at 21:33time echo "$(find /usr/share/doc/ | wc)"
takes about 1.7 seconds vs about 0.8 seconds astime find /usr/share/doc/ | wc
(with repeated runs to eliminate caching differences). – cas May 04 '22 at 00:55