当前位置:网站首页>shell遍历文件夹并输出
shell遍历文件夹并输出
2022-08-10 08:55:00 【RemoteDev】
dir=/usr #默认目录
if [ -n "$1" ]; then //如果参数1 不为空
dir=$1 #修改默认目录为参数值
echo "目录:${dir}" #显示目录
else
echo "第一个参数为空"
fi
cd ${dir} #进入目录
#循环遍历目录`ls -d */`指令取得目录集合
for item in `ls -d */`; do
echo ${item} #输出目录
done
效果:
边栏推荐
猜你喜欢
DataStream API(基础篇) 完整使用 (第五章)
FPGA中BEL Site Tile FSR SLR分别指什么?
UGUI—事件,iTween插件
Solve the problem that the win10win7win8 system cannot find the specified module and cannot register the desert plug-in
js reduce
UGUI - Events, iTween Plugin
CV+Deep Learning——网络架构Pytorch复现系列——classification(三:MobileNet,ShuffleNet)
Unity—UGUI control
Uni-app develops WeChat applet using local images as background images
Binary tree --- heap
随机推荐
设计分享|基于单片机的从左到右流水灯
日期类(暑假每日一题 19)
DAY25: Logic vulnerability recurrence
How AliExpress sellers seize product search weight
FPGA的虚拟时钟如何使用?
Different command line styles
J9 digital science: Web 3.0 is about data ownership or decentralized?
StringUtils的具体操作
shell之函数和数组
DAY25: Logic Vulnerability
幂次方(暑假每日一题 20)
Flink快速上手 完整使用 (第二章)
1499. The maximum pile.then/deque
组合数模板
J9数字科普:Web 3.0 是关于数据所有权还是去中心化?
[深入研究4G/5G/6G专题-56]: L3信令控制-5-无线承载管理
iwemeta metaverse: Ali's first COO: how to build a sales force
并查集学习
刷题工具h
Rust learning: 6.1_Slices of composite types