
1 2
| grep -i "要查找的单词" 要查找的文档
|

1 2
| grep -n "要查找的单词" 要查找的文档
|

1 2
| grep -w "要查找的单词" 要查找的文档
|

1 2
| grep -v "要排除的单词" 要查找的文档
|

1 2
| grep -e "查找单词1" -e "查找单词2" 要查找的文档
|

用ls -l | grep "关键字"
可以查找文件夹中含有某些字符的文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| root@DESKTOP-FH09R9R:/etc -rw-r--r-- 1 root root 2319 Jan 7 2022 bash.bashrc -rw-r--r-- 1 root root 1748 Jan 7 2022 inputrc -rw-r--r-- 1 root root 288 Mar 18 2022 mecabrc -rw-r--r-- 1 root root 11204 Feb 9 2022 nanorc drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc0.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc1.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc2.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc3.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc4.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc5.d drwxr-xr-x 1 root root 4096 Mar 22 08:37 rc6.d drwxr-xr-x 1 root root 4096 May 2 2023 rcS.d -rw-r--r-- 1 root root 3663 Jun 20 2016 screenrc -rw-r--r-- 1 root root 4942 Jan 24 2022 wgetrc root@DESKTOP-FH09R9R:/etc drwxr-xr-x 1 root root 4096 Mar 22 08:36 mysql
|
用apt list --installed | grep "关键字"
可以查找到安装了的软件里面含有该关键字的有哪些
1 2 3 4 5 6 7 8 9 10
| root@DESKTOP-FH09R9R:/etc
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
mysql-client-8.0/jammy-updates,jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-client-core-8.0/jammy-updates,jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-common/jammy,now 5.8+1.0.8 all [installed,automatic] mysql-server-8.0/jammy-updates,jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-server-core-8.0/jammy-updates,jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-server/jammy-updates,jammy-security,now 8.0.36-0ubuntu0.22.04.1 all [installed]
|
快速列出含有mysql关键字的包版本
sudo apt list --all-versions | grep "mysql" | grep "8.0"
这样可以同时搜索两个关键字and与逻辑
sudo apt list --all-versions | grep -e "mysql" -e "8.0"
这样可以同时搜索两个关键字or或逻辑
sudo apt list --all-versions | grep -v "lib" | grep "mysql"
这样可以排除一些不需要的关键字后再搜索,是非的逻辑
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| $ sudo apt list --all-versions | grep "mysql" [sudo] password for brian:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
mysql-client-8.0/jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-client-core-8.0/jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-client/jammy-security 8.0.36-0ubuntu0.22.04.1 all mysql-common/now 5.8+1.0.8 all [installed,local] mysql-router/jammy-security 8.0.36-0ubuntu0.22.04.1 amd64 mysql-server-8.0/jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-server-core-8.0/jammy-security,now 8.0.36-0ubuntu0.22.04.1 amd64 [installed,automatic] mysql-server/jammy-security,now 8.0.36-0ubuntu0.22.04.1 all [installed] mysql-source-8.0/jammy-security 8.0.36-0ubuntu0.22.04.1 amd64 mysql-testsuite-8.0/jammy-security 8.0.36-0ubuntu0.22.04.1 amd64 mysql-testsuite/jammy-security 8.0.36-0ubuntu0.22.04.1 all
|