Jacky's blog
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)

Jack Yang

编程; 随笔
首页
  • 学习笔记

    • web
    • android
    • iOS
    • vue
  • 分类
  • 标签
  • 归档
收藏
  • tool
  • algo
  • python
  • java
  • server
  • growth
  • frida
  • blog
  • SP
  • more
GitHub (opens new window)
  • shell

    • shell 入门指南
    • linux 入门指南
    • Shell 常用命令速查手册
    • Shell 代码片段集合
    • awk
    • fd
      • base
      • common options
      • case
      • git 相关
    • ftp
    • sftp
    • ifconfig
    • ssh
    • sed
    • xargs
  • tool

  • 网络

  • algo

  • compute_base

  • blog

  • growth

  • java

  • C&C++

  • ai

  • secure

  • cms

  • english

  • 生活

  • 金融学

  • more

  • other
  • shell
Jacky
2024-10-10
目录

fd

fd(find entries in the filesystem) 是一个用于在命令行中快速查找文件和目录的工具, 而不需要使用复杂的正则表达式。它类似于 find 命令, 但具有更简洁的语法和更友好的用户界面。 可以与 shell 结合使用, 通过在命令行中指定搜索模式和目录路径, 来查找匹配的文件和目录。它支持递归搜索, 并提供一些有用的选项来过滤和定制搜索结果

# base

fd [选项] 搜索模式 [目录]
1

其中, 搜索模式 是要查找的文件或目录的名称模式。目录 是要在其中进行搜索的起始目录路径。如果未指定目录路径, 则默认从当前目录开始递归搜索

# common options

  • man fd, fd --help: help
  • -i: case-sensitive
  • -a: 搜索隐藏文件和目录
  • -t <类型>: 只搜索指定类型的文件或目录(例如, -t f 用于只搜索文件)
  • -e <扩展名>: 只搜索具有指定扩展名的文件
  • -x <文件系统>: 排除指定文件系统的搜索结果
  • -s: 按文件大小进行排序
  • -0, --print0: Separate search results by the null character (instead of newlines).
  • -d, --max-depth: Limit directory traversal to at most d levels of depth. By default, there is no limit on the search depth
  • -p, --full-path: By default, the search pattern is only matched against the filename (or directory name). Using this flag, the pattern is matched against the full path
  • -E, --exclude: Exclude files/directories that match the given glob pattern

# case

  • fd -e log . ../: search for all files inside the '../' directory, use a match-all pattern fd . '../'
  • fd -e apk -0 . ../ | xargs -0 ls -lt | head -n 3: apk 倒叙,仅显示 3 个
使用 glob pattern 来排除特定的文件或目录
  • fd -e txt --exclude "*.log": 这个命令会查找所有 .txt 文件,但排除所有以 .log 结尾的文件
  • fd --exclude "node_modules": 排除某个特定目录下的文件

# git 相关

  • fd -t d -H .git: 查找当前目录下所有包含 .git 文件夹的目录(即 git 管理的项目)
  • fd -t d -H .git -d 1: 只查找当前目录下一级子目录中的 git 项目
  • fd -t d -H .git --max-depth 2: 查找当前目录下最多2层深度的 git 项目
  • fd -t d -H .git -x basename: 只显示 git 项目的文件夹名称(不显示路径)
  • fd -t d -H .git -d 2 --exclude "*gitlab*": 查找 git 项目但排除包含 gitlab 的目录
  • fd -t d -H .git -d 2 --exclude "*gitlab*" | sed 's|/.git/$||': 提取所有 git 项目的名称(去掉路径和 .git 后缀)
上次更新: 2025/07/21, 21:50:24
awk
ftp

← awk ftp→

最近更新
01
npx 使用指南
10-12
02
cursor
09-28
03
inspect
07-20
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Jacky | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式