0
我正在编写一个shell脚本,我需要将文件夹存储在数组中的特定路径中。列出指定路径中的文件夹 - Shell脚本
如:$ DEST_FOLDER = /选择/家庭的/ etc/
我需要在DEST_FOLDER子文件夹中存储到一个数组。
在此先感谢。
我正在编写一个shell脚本,我需要将文件夹存储在数组中的特定路径中。列出指定路径中的文件夹 - Shell脚本
如:$ DEST_FOLDER = /选择/家庭的/ etc/
我需要在DEST_FOLDER子文件夹中存储到一个数组。
在此先感谢。
a=(`find "$DEST_FOLDER" -type d`)
实施例:
[email protected]:~$ DEST_FOLDER=/home/susam/www/iptoc/p
[email protected]:~$ a=(`find $DEST_FOLDER -type d`)
[email protected]:~$ echo ${#a[*]}
5
[email protected]:~$ echo ${a[0]}
/home/susam/www/iptoc/p
[email protected]:~$ echo ${a[1]}
/home/susam/www/iptoc/p/include
[email protected]:~$ echo ${a[2]}
/home/susam/www/iptoc/p/data
[email protected]:~$ echo ${a[3]}
/home/susam/www/iptoc/p/rss
[email protected]:~$ echo ${a[4]}
/home/susam/www/iptoc/p/files
[email protected]:~$ echo ${a[5]}
[email protected]:~$