1殊橙、使用for循環(huán) -文件內(nèi)容
for line in `cat filename`
do
echo $line
done
or
for line in $(cat filenames)
do
echo $line
done
2、使用for循環(huán) -文件名稱
for line in `ls path`
do
echo $line
done
or
for line in $(ls path)
do
echo $line
done
3.使用while循環(huán) -文件名稱
while read line
do
echo $line
done < filename
4.使用source循環(huán) 讀取配置文件
#! bin/bash
source config
echo $pramaeter1
echo $pramaeter2
echo ...
5.使用while循環(huán) -讀取配置文件
#!/bin/bash
for line in `cat file`
do
eval "$line"
done
echo $pramaeter1
echo $pramaeter2
echo ...
or
#!/bin/bash
for line in $(cat file)
do
eval "$line"
done
echo $pramaeter1
echo $pramaeter2
echo ...