简体   繁体   English

Shell 脚本回显问题

[英]Shell script echo issue

In this if condition for shell script, i want print user full name + exist(if the file..../pub_key.asc found)or not exist if the mentioned file not found .在这个 shell 脚本的 if 条件下,我想要打印用户全名 + 存在(如果找到文件..../pub_key.asc)或者如果找不到提到的文件则不存在

for file in $FILES
do
if [ -f  /home/$file/public_html/pub_key.asc ]; then
     echo $(cat /home/$file/etc/passwd | head -n | cut -d: -f1) : Exists
else
    echo  $(cat /home/$file/etc/passwd | head -n | cut -d: -f1) : Not exists!
fi
done

But i get errors because there is something wrong with first echo in if..condition.但是我收到错误,因为 if..condition 中的第一个 echo 有问题。 Can someone show tell me what i did worng in the echo statement?有人可以告诉我我在 echo 语句中做了什么吗? and how to fix?以及如何解决? appreciate your suggestions.感谢您的建议。 :) :)

You are probably getting an error due to head -n command您可能由于head -n命令而收到错误

head -n has to be followed by a number, eg head -n 1 , or head -1 head -n后面必须跟一个数字,例如head -n 1head -1

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

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