最近在学习写shell脚本,在练习if while等流程控制时,突然它们的死循环写法是怎么样的?经过百度与亲测记录如下:
for死循环
#! /bin/bashfor ((;;));do date sleep 1done
while死循环
#! /bin/bashwhile :do date sleep 1done
#! /bin/bashwhile ((1))do date sleep 1done
#! /bin/bashwhile [[ 1 ]]do date sleep 1done
#! /bin/bashwhile [ 1 ]do date sleep 1done
#! /bin/bashwhile truedo date sleep 1done
#! /bin/bashwhile [[ "1" == "1" ]]do date sleep 1done
#! /bin/bashwhile test "1" = "1"do date sleep 1done
#! /bin/bashwhile [ TRUE ]do date sleep 1done