如何隐藏 bash 脚本中未找到的命令?我很好奇,因为除了草率的“命令未找到消息”之外,一切都运行良好
read user_name
if $user_name && exit 2> /dev/null
then
exit 0
elif egrep "^${user_name}": /etc/passwd 2> /dev/null
then
finger $user_name
exit 0
elif
until egrep "^${user_name}:" /etc/passwd || $user_name && "exit" 2> /dev/null
do
echo "try again or type exit to quit"
read user_name
if egrep -i "^${user_name}": /etc/passwd
then
finger $user_name
fi
done
then
finger $user_name
exit 0
fi
这是我遇到的错误
./project.sh: line 49: (myusernameisherebutimhidingit): command not found
最佳答案
问题是您尝试在多个位置运行命令 $user_name
,您可能希望将 $user_name
替换为检查用户名的值。
关于linux - 隐藏命令未找到 bash 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36585808/