Site icon David Yin's Blog

Shell While command

I want a shell script to run 50 times.
So I google it and got the answer. I put it here as a notes.
The script is for bash shell.

#!/bin/bash
i=0
while [ $i -lt 50 ]; do
echo "It is a test"
let i=i+1
done

Please be careful when enter the command, the space between the while command.
I save it as bat.sh and give 755 permission.

Exit mobile version