3 篇文章带有标签 “grep”

命令grep

  • 忽略字母大小写(-i)
grep -i 'text' hello.txt
  • 搜索多个文件
grep 'text' hello.txt hi.txt
  • 搜索当前目录下所有文件
grep 'text' *
  • 搜索当前目录(包含子目录 -R)下所有文件
grep -R 'text' *
  • 搜索 pip 配置文件的路径(增加过滤)
find ~ -name pip* | xargs -i grep "index-url" {} --color -nH
/home/lnsoft/.config/pip/pip.conf:2:index-url = https://mirrors.aliyun.com/pypi/simple/
  • 只匹配字符串,不使用正则表达式。
find . | grep -F .run
  • 显示当前目录下的文件
ll | grep '^-'
  • 显示当前目录下的所有目录及子目录(遍历)
ll -R | grep '^d'
  • 统计目录数
ll | grep '^d' | wc -l

Linux上查找系统信息

  • /proc/version
$ cat /proc/version
Linux version 4.18.0-147.5.1.el8_1.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Wed Feb 5 02:00:39 UTC 2020
  • hostnamectl
$ hostnamectl | grep Kernel
            Kernel: Linux 4.18.0-147.5.1.el8_1.x86_64
  • Ubuntu
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04 LTS
Release:	20.04
Codename:	focal
  • CentOS
LSB Version:	:core-4.1-amd64:core-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 8.1.1911 (Core) 
Release:	8.1.1911
Codename:	Core

/proc/driver/nvidia/version $ cat /proc/dr