列出指定路径下的文件夹- Shell脚本



我正在编写一个shell脚本,我需要将文件夹存储在数组的特定路径中。

例如:$DEST_FOLDER =/opt/home/etc/

我需要将DEST_FOLDER中的子文件夹存储到数组中。

a=( `find "$DEST_FOLDER" -type d` )

的例子:

susam@nifty:~$ DEST_FOLDER=/home/susam/www/iptoc/p
susam@nifty:~$ a=( `find $DEST_FOLDER -type d` )
susam@nifty:~$ echo ${#a[*]}
5
susam@nifty:~$ echo ${a[0]}
/home/susam/www/iptoc/p
susam@nifty:~$ echo ${a[1]}
/home/susam/www/iptoc/p/include
susam@nifty:~$ echo ${a[2]}
/home/susam/www/iptoc/p/data
susam@nifty:~$ echo ${a[3]}
/home/susam/www/iptoc/p/rss
susam@nifty:~$ echo ${a[4]}
/home/susam/www/iptoc/p/files
susam@nifty:~$ echo ${a[5]}
susam@nifty:~$

最新更新