Created
August 22, 2023 11:22
-
-
Save zorchp/93b23bf96eb22f70235b4f38c1996796 to your computer and use it in GitHub Desktop.
文本处理的 Linux 工具使用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 查找指定文件中包含某关键字的指定行(显示行号) | |
# -n 显示行号 | |
grep -n "home" /etc/passwd | |
# 需要先打印模式匹配然后打印行号, 比较麻烦 | |
sed -ne '/home/p' -e '/home/=' /etc/passwd | |
### 查找某些特定文件(例如通过扩展名)中出现的关键字的对应文件名和行号 | |
grep -rn "process" --include='*.cpp' . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment