user788171
user788171

Reputation: 17553

bash input/output redirect doesn't work

Can anybody tell me what is wrong with the following bash code

for f in $FILES
do
  cut -d, f1-7 < $f > $f.tmp
done

When I run in the loop

echo "cut -d, f1-7 < $f > $f.tmp"

I get the right command output and when I run that command by itself, it works perfectly. But when I run it in the bash loop, it doesn't work, I get the following error:

cut: you must specify a list of bytes, characters, or fields
Try `cut --help' for more information.

Any ideas?

Upvotes: 0

Views: 1086

Answers (1)

Stephane Rouberol
Stephane Rouberol

Reputation: 4384

I think you miss a minus sign in your cut command:

cut -d, -f1-7 < $f > $f.tmp

Upvotes: 3

Related Questions