In the shell for loop commonly used to perform a limited number of cycles, and while it is generally an infinite loop, and so on for daemons
grammar:
i: variable name
words: variable ranges
command: Command
for i in words; do
#command
done
Off now, we use a for loop to write a simple script to display the file in the current directory:
words=`ls /root/`
for i in words; do
echo $i
done
[root@node1]# sh test.sh
anaconda-ks.cfg
bootime.svg
git_test
monitor
null
carry out!