查找,保存文件
#!/bin/bash
#查找当前目录下的.svn目录,将其路径保存到数组中
svnPathArray=$(find . -name .svn)
#echo ${svnPathArray[@]}
file=.tmp.svnPathArray
#当该文件存在时,清空内容,如果不存在则创建
if [ -f ${file} ];
then
> ${file}
else
touch ${file}
fi
#将数组内容逐条插入到文件中
for i in ${svnPathArray}
do
echo $i >> ${file}
done
读取本地文件存入数组中
#!/bin/bash
array=$(cat $1)
for i in ${array}
do
echo ${i}
done
#!/bin/bash
cat $1|while read line
do
echo $line
done
关于shell数组的操作
http://blog.csdn.net/jerry_1126/article/details/52027539