#!/bin/bash
# 定义一个方法 它有一个参数代表目录
foreachd(){
        for file in $1
            do
                if [ -d $file ]
                then
                    echo $file"是目录" 
                    foreachd $file
                elif [ -f $file ]
                then
                    echo $file
                fi
            done
}

# 执行,如果有参数就遍历指定的目录,否则遍历当前目录
if [[ "x$1" == 'x' ]]
then
    foreachd "."
else
    foreachd "$1"
fi 

 

相关文章:

  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-08-10
  • 2021-07-08
  • 2022-01-20
  • 2021-09-03
相关资源
相似解决方案