day7-查看文档

cat Concatenate

cat 选项 文件名

-n 在每一行(含空行)前显示行号

more less 分屏阅读

more 选项 文件名

缺点:不方便向前翻页

Enter键下翻一行 

空格键下翻一屏

b键向上翻一屏

q或Q 键退出 

/键后查找

?键了解操作说明

less

less 选项 文件名

优点:支持前后翻页

PgUp向前翻页

PgDn向后翻页

?键向前 按/键向后查找(n,N切换)

more最基本的文本阅读器

less是增强型的文本阅读器,功能更多

文件首/尾部

head tail

head -n 数字 文件名 默认为10行 -n 或-数字

文件的14-15行

[root@localhost test]# head -n 15 /etc/passwd|tail -n 2

ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin

nobody:x:99:99:Nobody:/:/sbin/nologin

文本统计

wc Word Count

wc 选项 文件名

wKioL1evBx6CcVsFAABCZxUNuVg435.png

文件的行数

[root@localhost test]# wc -l /etc/services 

10774 /etc/services

多少个配置文件

[root@localhost test]# ll /etc/*.conf|wc -l

46

grep 条件条件检索文本

grep 选项 '查找条件'

-i 查找时忽略大小写

-v 反转查找,输出不符合查找条件的行

--color 突出显示查找字符串

双引号内指定查找的字符串

^.. 表示以..开头

..$ 表示以..结尾

^$ 表示空行

wKiom1evCWmyOSYoAAAtA9GldBg277.png

[root@localhost test]# dmesg |grep 'eth' --color

eth0: no IPv6 routers present

去#号开头的文本

grep -v '^#' /etc/vsftpd/vsftpd.conf 

当前/bin/bash登录shell的个数

[root@localhost test]# grep -c '/bin/bash' /etc/passwd

4

去空格和以#号开头的文本

grep -E -v '^#|^$' /etc/vsftpd/vsftpd.conf

原文地址:https://www.cnblogs.com/fina/p/5781829.html