Clone
6
每天一个linux 命令.md
newde edited this page 2026-03-26 09:17:29 -04:00
This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

第一天find

$find /home/newde/c++ -name "*.cpp" | xargs grep -in "for"

  • find fand 命令
  • /home/newde/c++ 路径 从那里找
  • “*.cpp”: 查找什么文件
  • | : 管道命令,把前面的输出 传递到后面作为输入。 👍
  • xargs: 给其它命令传递参数 有这个参数才能把这些找到内容传递给 grep
  • grep: 在文件中搜索
  • -i: 不区分大小写 就是大小写都一样
  • -n: 就是行号,在*.cpp 文件内第几行
  • “for” : 找所有 *.cpp 里面包含 for 字符的
  1. fing /home/newde/c++ -name "*.cpp"

    输出 1.cpp    2.cpp    3.cpp

  2. 接上面 xargs grep -in "for"

  3. 相当于 grep -in "for" 1.cpp 2.cpp 3.cpp

  4. grep 在后面的文件中找 for 字符 不分大小学,列出行号。