iT邦幫忙

第 12 屆 iThome 鐵人賽

0
自我挑戰組

30天菜鳥學 Linux 系列 第 46

第46天-fd-find 代替 find

  • 分享至 

  • xImage
  •  

使用 fd-find 代替 find,效率更好
下載方式 :

sudo apt-get install fd-find
test@test:~$ sudo apt-get install fd-find
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  fd-find
0 upgraded, 1 newly installed, 0 to remove and 60 not upgraded.
Need to get 721 kB of archives.
After this operation, 2,462 kB of additional disk space will be used.
Get:1 http://hk.archive.ubuntu.com/ubuntu focal/universe amd64 fd-find amd64 7.4.0-2build1 [721 kB]
Fetched 721 kB in 2s (342 kB/s)
Selecting previously unselected package fd-find.
(Reading database ... 133991 files and directories currently installed.)
Preparing to unpack .../fd-find_7.4.0-2build1_amd64.deb ...
Unpacking fd-find (7.4.0-2build1) ...
Setting up fd-find (7.4.0-2build1) ...
Processing triggers for man-db (2.9.1-1) ...

避免命令名稱衝突情況,使用 alias

alias 替代名稱=原命令名稱

幫助

test@test:/$ fdfind -h
fd 7.4.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)
    -g, --glob              Glob-based search (default: regular expression)
    -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
    -X, --exec-batch <cmd>             Execute a command with all search results at once
    -E, --exclude <pattern>...         Exclude entries that match the given glob pattern
    -c, --color <when>                 When to use colors: never, *auto*, always
    -S, --size <size>...               Limit results based on the size of files.
        --changed-within <date|dur>    Filter by file modification time (newer than)
        --changed-before <date|dur>    Filter by file modification time (older than)

ARGS:
    <pattern>    the search pattern: a regular expression unless '--glob' is used (optional)
    <path>...    the root directory for the filesystem search (optional)

Note: `fd -h` prints a short and concise overview while `fd --help` gives all details.

找尋 java 檔案

test@test:/$ fdfind -e java
home/test/Demo.java

查找 password 名稱檔案,有高亮效果

test@test:/$ fdfind 'password'

xxx

查找 path 類型檔案,名稱包含 password

fdfind -e path 'password'

xxx

預設不區分大小寫,可以加-tf區分大寫,注意小寫不行喔!!

test@test:~$ touch Demo
test@test:~$ touch demo
test@test:~$ ls
demo  Demo
test@test:~$ fdfind demo
Demo
demo
test@test:~$ fdfind -tf demo
Demo
demo
test@test:~$ fdfind -tf Demo
Demo

找尋後執行命令,像是找尋後刪除

test@test:~$ fdfind -tf Demo -x rm {}
test@test:~$ ls
demo

上一篇
第45篇-lsmod命令
下一篇
第47天-學習一次性排程工作 at
系列文
30天菜鳥學 Linux 59
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言