当前位置:网站首页>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
效果:

边栏推荐
猜你喜欢
随机推荐
CV+Deep Learning - network architecture Pytorch recurrence series - classification (3: MobileNet, ShuffleNet)
debezium-connector-mysql拉起docker报错:debezium启动docke
[In-depth study of 4G/5G/6G topic-56]: L3 signaling control-5-radio bearer management
Rust learning: 6.5_Array of composite types
shell之函数和数组
SQL优化总结
ARM体系结构2:处理器内核和汇编指令集
Delphi实现的一个文件在线查询显示下载功能
It is obvious that a unique index is added, why does it still generate duplicate data?
1499. The maximum pile.then/deque
PTA Exercise 2.1 Simple Calculator
DAY25: Logic vulnerability recurrence
速卖通卖家如何抓住产品搜索权重
刷题工具h
FPGA时钟篇(二) 7系列clock region详解
以技术御风险,护航云原生 | 同创永益 X 博云举办产品联合发布会
[深入研究4G/5G/6G专题-56]: L3信令控制-5-无线承载管理
并查集学习
Pieces of TensorFlow 2.9 (1)
Binary tree --- heap









