-1

I'm trying to run the following loop but unfortunately it creates empty files.

 for f in *.tex; do cut -d "&" -s -f1,2,4 $f | sed "s/$/\\\\\\\\/g" | sed "s/Reg. year/\$year/g" | sed "s/=\([0-9]\{4\}\)/^\{\1\}\$/g" | sed "/Counterfactual/d" | sed "/Delta/d" | sed "/{2014}/d" | sed "/^\s*&\s*\&/d" > $f; done;

When I run the command on a single file (replacing $f by filename.ext), it does work well.

Leda
  • 1

1 Answers1

0

You are piping whole for loop You can put all commands after do in beak brackets:

{ cut ... | sed ... | ... }

Or You can use xargs:

find ./ -type f -name "*.tex" -print0 | xargs -0 cut -d "&" -s -f1,2,4 | sed ... | ...
Kubator
  • 1,373
  • 4
  • 13