当前位置:网站首页>遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名
遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名
2022-06-26 12:41:00 【冷月宫主】
#!/bin/bash
######################################################################
## ##
## 遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名 ##
## ##
######################################################################
##递归遍历
traverse_dir()
{
filepath=$1
#echo $filepath
for file in `ls -a $filepath`
do
if [ -d ${filepath}/$file ]
then
if [[ $file != '.' && $file != '..' ]]
then
#递归
traverse_dir ${filepath}/$file
fi
else
#调用查找指定后缀文件
check_suffix ${filepath}/$file
fi
done
}
##获取后缀为txt或ini的文件
check_suffix()
{
file=$1
# if [ "${file##*.}"x = "txt"x ] || [ "${file##*.}"x = "ini"x ] || [ "${file##*.}"x = "gz"x ]; then
if [ "${file##*.}"x = "jar"x ]; then
echo $file
fi
}
#测试指定目录 /data_output/ci/history
traverse_dir $(cd "$(dirname "$0")";pwd)
边栏推荐
- Electron official docs series: Get Started
- Detailed practical sharing, two hours of funny videos after work, earning more than 7000 a month
- 享元模式(Flyweight)
- 首批通过!百度智能云曦灵平台获信通院数字人能力评测权威认证
- scrapy——爬取漫画自定义存储路径下载到本地
- I have a good word to say, and I admire myself
- ES基于Snapshot(快照)的数据备份和还原
- 7-2 a Fu the thief
- Ubuntu installation and configuration PostgreSQL (18.04)
- POJ 3070 Fibonacci
猜你喜欢

Mysql database explanation (III)

12 SQL optimization schemes summarized by old drivers (very practical)

Fire warning is completed within 10 seconds, and Baidu AI Cloud helps Kunming Guandu build a new benchmark of smart city

5月产品升级观察站

Common faults of MySQL database - forgetting database password

ES基于Snapshot(快照)的数据备份和还原

Processing polyhedron change

Arcpy - - utilisation de la fonction insertlayer (): ajout de calques dans un document de carte

C language: Exercise 2

Design of simple digital circuit traffic light
随机推荐
偶言佳句,孤芳自赏
Decorator
MongoDB系列之适用场景和不适用场景
5+api, clear application cache
Processsing mouse interactive learning
Map value
MySQL数据库讲解(六)
D - skiing
Electron official docs series: References
Prototype
A collection of common tools for making we media videos
Electron official docs series: Contributing
Hdu1724[Simpson formula for integral]ellipse
KITTI Tracking dataset whose format is letf_ top_ right_ bottom to JDE normalied xc_ yc_ w_ h
tauri vs electron
Beifu PLC realizes data power-off maintenance based on cx5130
Beifu PLC obtains system time, local time, current time zone and system time zone conversion through program
Oplg: new generation cloud native observable best practices
MySQL讲解(二)
Appearance mode (facade)