$ INPUT重定向暧昧 [英] $INPUT Ambiguous redirect

查看:122
本文介绍了$ INPUT重定向暧昧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我前一段时间写这个剧本,它工作正常,但由于某些原因,我现在得到一个暧昧重定向错误行11 cygwin的消息。

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?

推荐答案

如前所述删除空格。所以行显示输入= / Students.csv

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

包住$输入,所以它读取完成&LT; $ INPUT

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

我添加回声CP Rubric.pdf ./Grades/$flname_rubric.PDF所以你可以看到工作中的while循环。

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

这篇关于$ INPUT重定向暧昧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆