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

边栏推荐
- 设计分享|基于单片机的从左到右流水灯
- 详解构建mock服务最方便的神器——Moco
- 1 活动时间与安排
- m.bjhjwy.com全面教学设备 类型包括: 教学仪器, 教学设备 ,
- 打工人的第27天-平凡但不平淡的日子
- ARM结构体系3:ARM指令的寻址和异常中断处理
- ARM体系结构2:处理器内核和汇编指令集
- npm i安装报错
- [Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
- 凭借这份阿里架构师的万字面试手册,逆风翻盘,斩获阿里offer
猜你喜欢

Rust learning: 6.3_ Tuples of composite types

明明加了唯一索引,为什么还是产生重复数据?

day16--The use of the packet capture tool Charles

DAY25: Logic vulnerability recurrence

Uni-app develops WeChat applet using local images as background images

多线程浅谈
![[OAuth2] 20. OAuth2 Extended Protocol PKCE](/img/ff/37f3be22bf209222cadaf5d11f951a.png)
[OAuth2] 20. OAuth2 Extended Protocol PKCE

Flink运行时架构 完整使用 (第四章)

CV+Deep Learning - network architecture Pytorch recurrence series - classification (3: MobileNet, ShuffleNet)

ShardingSphere入门
随机推荐
以技术御风险,护航云原生 | 同创永益 X 博云举办产品联合发布会
Is the write performance of raid5 faster than raid10?
UGUI - Events, iTween Plugin
J9数字科普:Web 3.0 是关于数据所有权还是去中心化?
解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
Solve the problem that the win10win7win8 system cannot find the specified module and cannot register the desert plug-in
LaTeX出现错误代码Command \algorithmic already defined
【微服务架构】为故障设计微服务架构
高等数学(第七版)同济大学 习题4-3 个人解答
高性能短连接设计
多线程知识点总结之温故而知新
DAY26: GetShell project
菜鸟、小白在autojs和冰狐智能辅助之间如何选择?
不要把公司当成家,被通知裁员时会变得不幸...
大体来讲,网站会被攻击分为几种原因
Class Notes (7) (1) - #647. Find the root and the child (root)
[OAuth2] 20. OAuth2 Extended Protocol PKCE
【一起学Rust | 进阶篇 | RMQTT库】RMQTT消息服务器——安装与集群配置
Mongo的简单操作-数据库用户的查询、创建与删除
对称加密与非对称加密的区别