简体   繁体   English

我在编写“For Loop”语句时遇到问题,该语句检查文本文件是否存在

[英]I'm having trouble writing a “For Loop” statement that checks a text file to see if each exist in it

I'm writing a "for loo" statement that checks a test file to see if the mutiple entered arguments exists. 我正在编写一个“for loo”语句,用于检查测试文件以查看是否存在多个输入的参数。 The script I have written just returns the everything as if it exists even if it doesn't 我编写的脚本只返回所有内容,就好像它存在一样,即使它不存在

for i in "$@"
do
grep -q "$i" /home/s132a18/A10/cisStudents  && echo "$i is a student" || echo "$i is not a student"

done

When the word not is the only difference: 当单词not唯一的区别时:

for i in "$@"
do
   echo "$i is $(grep -q "$i" /home/s132a18/A10/cisStudents || echo "not ")a student"
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM