篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh bash for loops相关的知识,希望对你有一定的参考价值。
for VARIABLE in 1 2 3 4 5 .. N
do
command1
command2
commandN
done
for VARIABLE in file1 file2 file3
do
command1 on $VARIABLE
command2
commandN
done
#!/bin/bash
for i in 1 2 3 4 5
do
echo "Welcome $i times"
done
#!/bin/bash
for i in {1..5}
do
echo "Welcome $i times"
done
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
for i in {0..10..2}
do
echo "Welcome $i times"
done
#!/bin/bash
for (( c=1; c<=5; c++ ))
do
echo "Welcome $c times"
done
#!/bin/bash
for (( ; ; ))
do
echo "infinite loops [ hit CTRL+C to stop]"
done