本文是在windows下用编辑器写好shell脚本,然后使用cygwin运行脚本,所以文件路径开头会有其标识。
遍历文件夹及其文件,即获取指定文件下所有的文件夹名称和文件名称
#!/bin/bash
function getdir(){
for files in `ls $1`
do
echo $1"/"$files
if [ -d $1"/"$files ]
then
getdir $1"/"$files
fi
echo "------split------"
done
}
folder_path="/cygdrive/c/folder" #C盘下的folder为指定文件夹
getdir ${folder_path}
read -n 1
网友评论