linux常用命令行

查找文件

查找的时候排除某个目录

-not -path 或者 ! -path只是 在结果中过滤掉匹配的路径

sudo find / ! -path "/home/*" -type f -name CycloneDDSConfig.cmake

-prune 能直接避免进入目录,能真正减少搜索时间

-print 能够避免打印找到的 /Users/sjh/miniforge3/bin 这样的目录自身

find ~ -path "/Users/sjh/miniforge3/*" -prune -o -path "/Users/sjh/Library/*" -prune -o -path "*/.*" -o -type d -name "scripts" -print

查找并对找到的文件执行命令

# 对 example 文件夹下所有的代码利用 clang-format 进行格式化
find example/ -type f \( -name "*.h" -o -name "*.cpp" \) -exec clang-format -i {} \;
posted @ 2025-04-07 16:52  Atten  阅读(27)  评论(0)    收藏  举报