fd——命令行文件查找工具

fd——命令行文件查找工具

该项目的GitHub地址为:sharkdp/fd,可以执行比find命令更高效的文件查找操作。支持正则表达式。

安装

1
brew install fd

使用

直接查找

1
2
3
4
5
6
7
8
9
10
11
$ fd chapter

chapter10.R
chapter2.R
chapter3.R
chapter4.R
chapter5.R
chapter6.R
chapter7.R
chapter8.R
chapter9.R

按拓展名查找文件

1
2
3
$ fd -e csv

movies.csv

按正则表达式查找文件

1
2
3
4
5
6
fd '[0-9]\.jpeg$'

WechatIMG49167.jpeg
WechatIMG49185.jpeg
WechatIMG49579.jpeg
WechatIMG50967.jpeg

查看帮助文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
fd -h
fd 7.1.0

USAGE:
fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

FLAGS:
-H, --hidden Search hidden files and directories
-I, --no-ignore Do not respect .(git|fd)ignore files
--no-ignore-vcs Do not respect .gitignore files
-s, --case-sensitive Case-sensitive search (default: smart case)
-i, --ignore-case Case-insensitive search (default: smart case)
-F, --fixed-strings Treat the pattern as a literal string
-a, --absolute-path Show absolute instead of relative paths
-L, --follow Follow symbolic links
-p, --full-path Search full path (default: file-/dirname only)
-0, --print0 Separate results by the null character
-h, --help Prints help information
-V, --version Prints version information

OPTIONS:
-d, --max-depth <depth> Set maximum search depth (default: none)
-t, --type <filetype>... Filter by type: file (f), directory (d), symlink (l),
executable (x), empty (e)
-e, --extension <ext>... Filter by file extension
-x, --exec <cmd> Execute a command for each search result
-E, --exclude <pattern>... Exclude entries that match the given glob pattern
--ignore-file <path>... Add a custom ignore-file in .gitignore format
-c, --color <when> When to use colors: never, *auto*, always
-j, --threads <num> Set number of threads to use for searching & executing
-S, --size <size>... Limit results based on the size of files.

ARGS:
<pattern> the search pattern, a regular expression (optional)
<path>... the root directory for the filesystem search (optional)

把所有的jpeg文件转换为png文件

1
$ fd -e jpeg -x convert {} {.}.png

把所有的zip文件解压

1
$ fd -e zip -x unzip

统计所有的csv文件的行数

1
2
3
$ fd -x wc -l \; -e csv

58789 movies.csv
# shell

评论

程振兴

程振兴 @czxa.top
截止今天,我已经在本博客上写了659.4k个字了!

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×