一、cat命令
1、cat用途:显示文件的内容
ex: cat a.txt #显示a.txt文件中的内容

cat /proc/uptime

第一个值表示系统从开机到现在的时间(s)
第二个值表示系统开机后空闲的时间(s)
系统空闲比:第二个值/第一个值
2、命令格式:cat [选项] 文件名
ex:cat/etc/sysconfig/network-scripts/ifcfg-eth0 #查看网络配置文件

3、选项
-b:非空行加上序号
ex:cat -b/etc/sysconfig/network-scripts/ifcfg-eth0

-A :showall == -vET
ex:cat -A/etc/sysconfig/network-scripts/ifcfg-eth0 #将每行末尾换行符转换成$输出

-v:--show-nonprinting 使用^和M-引用,除LFD和TAB
-E,--show-ends 在每行结束处显示"$"
ex:cat -E/etc/sysconfig/network-scripts/ifcfg-eth0

-T, --show-tabs 将跳格字符显示为^I
ex: cat -T a.txt #将a.txt文件中的TAB表示成^I输出

二、Tac命令
1、tac用途
Tac:倒叙浏览,适用于查看系统日志等按时间更新的文件
2、命令格式
tac [选项] 文件名
ex:tac a.txt #倒序浏览a.txt文件

3、选项
-b:before 在行前而非行尾添加分隔标志

-r:regex 将分隔标志视作正则表达式来解析
ex:tac -r a.txt

-s:separator 使用指定字符串代替换行符做分隔标志
ex:tac -s aa.txt

三、more &less 命令
(一)、more命令
1、more
more:全屏方式分页显示文件内容
2、命令格式
more [选项] 文件名
ex:more/var/log/dmesg #查看dmesg日志文件

3、操作方法
1、enter:向下逐行滚动
2、space:向下逐页翻动
3、q:退出
(二)、less命令
1、less
less:与more功能相同,但扩展功能更多
2、命令格式
less [选项] 文件名
ex:less/var/log/dmesg

3、操作方法
1、PgUP :上翻页
2、PgDn :下翻页
3、‘/’键查找内容,‘n’下一个内容,‘N’上一个内容

四、head&tail 命令
1、Head
head:查看文件开头的前十行(默认)
ex:head/var/log/dmesg #显示dmesg文件的前十行

选项:-n :n代表行数
ex:head -11/var/log/dmesg #显示dmesg文件的前11行

2、tail
tail:查看文件末尾的后十行(默认)
ex:tail/var/log/dmesg #显示dmesg文件的后十行

选项:
1、-n:n代表行数
ex:tail -11 /var/log/dmesg #显示dmesg文件的后11行

2、-f :跟踪文件末尾的内容变化,实时显示更新的内容
网友评论