0

I have a list of files in the same parent directory all of which have a .new extension (for example 1001O5V.new).

All of these files have two columns (column 1 wavelength, column 2 flux).

I need to make a loop into each file and extract only those values which have $1 > 3599.99 && $1 < 7400.01

I'm currently trying this:

for f in *.new; do
    awk '{if ($1 > 3599.99 && $1 < 7400.01) print $1,$2}' ${f} > ${f}
done

But the files are replaced with blank files! What am I doing wrong?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Stp30
  • 125
  • 1
  • 8
  • @Benjamin W. - I agree that the answers mentioned in the post you provide are similar. But what I'm looking for is the same process for multiple files – Stp30 Jul 09 '18 at 16:11
  • 1
    You can just do `for f in *.new; do awk '...' "$f" > "$f.tmp" && mv "$f.tmp" "$f"; done`, or if you have GNU awk, see https://stackoverflow.com/questions/16529716/awk-save-modifications-in-place – Benjamin W. Jul 09 '18 at 16:13

0 Answers0