显示文件
文件显示命令虽然比较简单,但是他们在将来的命令中,起到了连接命令的功能,因此实际上是很复杂的,特别是cat命令。
cat
cat全部显示文件内容,并不停留,
命令:
cat file1 file2 file3 …
cat后面带的是文件列表,比如
cat /etc/*conf
[zhangwei@localhost ~]$ cat ab.conf
1 #
2 # Place your global alsa-lib configuration here...
cat -n
cat -n 显示带行号的文本。
比如
[zhangwei@localhost ~]$ cat -n asound.conf
1 #
2 # Place your global alsa-lib configuration here...
3 #
4 #tttt
5 #ttt
6 #txxxxxxxxxxxxx
nl
同cat -n,不过空行nl不计数。
more
因为cat显示文件会速度快看不见全貌,因此more可以一页一页的翻看
显示命令
回车: 看下一行
ctrl+f, f: 前一页
ctrl+b,b:后一页
q:退出
less
同more,不过他支持上下键滚动文本内容。
head
默认看文件的前10行,如果看到具体的行数
[zhangwei@localhost ~]$ cat asound.conf
#
# Place your global alsa-lib configuration here...
#
#tttt
#ttt
#txxxxxxxxxxxxx
[zhangwei@localhost ~]$ head -n 1 asound.conf
#
[zhangwei@localhost ~]$ head -n 2 asound.conf
#
# Place your global alsa-lib configuration here...
[zhangwei@localhost ~]$ head -n -2 asound.conf
#
# Place your global alsa-lib configuration here...
#
#tttt
-n: -2 表示直接显示到最后第二行停止。
-n: 2 显示前2行。
默认显示前10行。
tail
默认显示后10行。
tail -n 1 : 显示尾部1行
tall -n +10, 从第10行显示到文件尾部。
作者:严锋 创建时间:2024-04-20 13:13
最后编辑:严锋 更新时间:2025-05-09 15:48
最后编辑:严锋 更新时间:2025-05-09 15:48