Shell 脚本 - 使用带有 if 语句的 source 命令
Shell script - using source command with if statement
我有一个使用 if 语句的脚本,如下所示:
if [ "$_nowTime" \> "$_authExpiration" ]; then
echo "Your last token has expired"
promptForMFA
fi
当我通过“source”或“'”命令 运行 它时,我收到错误“预期条件:>”,似乎源不喜欢反斜杠,以防我删除它,它把它当作一个管道并创建一个文件。
通过添加另一个方块解决:
如果 [[ "$_nowTime" > "$_authExpiration" ]]
我有一个使用 if 语句的脚本,如下所示:
if [ "$_nowTime" \> "$_authExpiration" ]; then
echo "Your last token has expired"
promptForMFA
fi
当我通过“source”或“'”命令 运行 它时,我收到错误“预期条件:>”,似乎源不喜欢反斜杠,以防我删除它,它把它当作一个管道并创建一个文件。
通过添加另一个方块解决: 如果 [[ "$_nowTime" > "$_authExpiration" ]]