$INPUT Ambiguous redirect

2019-04-15 16:18发布

I wrote this script a while ago and it worked fine, but for some reason I am getting a "Ambiguous redirect" error message for line 11 in cygwin now.

#!/bin/bash
cd 'my/file/path'
INPUT= ./Students.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read flname
do
    cp Rubric.pdf ./Grades/$flname_rubric.PDF

done < $INPUT
IFS=$OLDIFS

What am I doing wrong here?

2条回答
霸刀☆藐视天下
2楼-- · 2019-04-15 17:03

As already noted remove the space. so line reads INPUT=./Students.csv

Wrap the $INPUT in "" so it reads done < "$INPUT"

I added echo "cp Rubric.pdf ./Grades/$flname_rubric.PDF" so you can see the while loop at work.

#!/bin/bash
INPUT=./Students.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
echo "While "
while read flname
do
    echo "cp Rubric.pdf ./Grades/$flname_rubric.PDF"
    cp Rubric.pdf ./Grades/$flname_rubric.PDF
done < "$INPUT"
IFS=$OLDIFS
查看更多
唯我独甜
3楼-- · 2019-04-15 17:13

Try removing the space after the equals sign in INPUT=.

查看更多
登录 后发表回答