#!/bin/bash function getdir(){ for element in `ls $1` do dir_or_file=$1"/"$element if [ -d $dir_or_file ] then getdir $dir_or_file else echo $dir_or_file fi done } root_dir="$1" getdir $root_dir
测试:
参考;https://www.cnblogs.com/xiaopipi/p/6214673.html