我目前正在编写我的第三个 shell 脚本,但遇到了一个问题。到目前为止,这是我的脚本:
#!/bin/bash
echo "choose one of the following options : \
1) display all current users \
2) list all files \
3) show calendar \
4) exit script"
while read
do
case in
1) who;;
2) ls -a;;
3) cal;;
4) exit;;
esac
done
Run Code Online (Sandbox Code Playgroud)
当我尝试运行脚本时,它说:
line2 : unexpected EOF while looking for matching '"'
line14 : syntax error: unexpected end of file.
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我正在尝试编写一个 shell 脚本,该脚本从用户那里获取字符串输入,询问文件名并报告该字符串是否存在于文件中。下面是我当前的脚本。
#!/bin/bash
while :
do
echo "Please enter a string"
read input_string
echo "Please enter the file name to see if that string is present in it - (Enter .abw after)"
read input_string1
grep -q "${input_string}" "${input_string1}"
if grep -q $input_string $input_string1 ; then
echo "Your string has been found"
else
echo "Your string has not been found"
fi
done
Run Code Online (Sandbox Code Playgroud)
当我运行脚本时,它说
Line 2: while:: command not found
Line 3: syntax error near unexpected token 'do'
Line 3: 'do' …Run Code Online (Sandbox Code Playgroud) 这可能是一个相当简单的问题,但在这里。
我正在考虑学习使用 CLI,因为有人告诉我,技术人员使用它比 GUI 更有效。有人可以概述为什么使用 CLI 是有益的吗?