Shell keyword 「while」
type while
執行
$ type while
顯示
while is a shell keyword
help while
執行
$ help while
顯示
while: while COMMANDS; do COMMANDS; done
Execute commands as long as a test succeeds.
Expand and execute COMMANDS as long as the final command in the
`while' COMMANDS has an exit status of zero.
Exit Status:
Returns the status of the last command executed.
範例001
server.sh
#!/usr/bin/env bash
while true; do
date;
sleep 1;
done
設定可執行
$ chmod u+x server.sh
執行
$ ./server.sh