我正在尝试在 bash 中编写一个 if 语句,如果提供的变量不是整数,该语句将退出。我最终会将这个 if 语句嵌套在 while 循环中。
当我运行此命令时,我收到语法错误。
#!/bin/bash if [ $f1 != ^[0-9]+$ ] then exit 1 fi
variables bash integer if-statement
bash ×1
if-statement ×1
integer ×1
variables ×1