开发者

List folders in specified path - Shell script

开发者 https://www.devze.com 2023-03-23 13:55 出处:网络
Im writ开发者_JS百科ing a shell script where I need to store the folders in a particular path in an array.

Im writ开发者_JS百科ing a shell script where I need to store the folders in a particular path in an array.

Eg: $DEST_FOLDER = /opt/home/etc/

I need to store the subfolders in the DEST_FOLDER into an array.

Thanks in advance.


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

Example:

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:~$
0

精彩评论

暂无评论...
验证码 换一张
取 消