linux常用命令-查看文本/cat,tac,more,less,head,tail
cat:連接并顯示文件
NAME
?????? cat - concatenate files and print on the standard output
[root@localhost ~]# cat /etc/issue
Red Hat Enterprise? Server release 6.6 (Santiago)
\m
[root@localhost ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Jun 21 02:15:00 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 /?????????????????????? ext4??? defaults??????? 1 1
UUID=2622a4b4-ddc9-47a3-aa2b-f06bc9bec085 /boot?????????????????? ext4??? defaults??????? 1 2
UUID=33d94759-fa01-4c4f-b4ac-bf3a1fe5e84f swap??????????????????? swap??? defaults??????? 0 0
tmpfs?????????????????? /dev/shm??????????????? tmpfs?? defaults??????? 0 0
devpts????????????????? /dev/pts??????????????? devpts? gid=5,mode=620? 0 0
sysfs?????????????????? /sys??????????????????? sysfs?? defaults??????? 0 0
proc??????????????????? /proc?????????????????? proc??? defaults??????? 0 0
[root@localhost ~]# cat /etc/issue /etc/fstab
Red Hat Enterprise? Server release 6.6 (Santiago)
\m
#
# /etc/fstab
# Created by anaconda on Sun Jun 21 02:15:00 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=57d85756-7680-4c7c-9125-6ad67dae2c45 /?????????????????????? ext4??? defaults??????? 1 1
UUID=2622a4b4-ddc9-47a3-aa2b-f06bc9bec085 /boot?????????????????? ext4??? defaults??????? 1 2
UUID=33d94759-fa01-4c4f-b4ac-bf3a1fe5e84f swap??????????????????? swap??? defaults??????? 0 0
tmpfs?????????????????? /dev/shm??????????????? tmpfs?? defaults??????? 0 0
devpts????????????????? /dev/pts??????????????? devpts? gid=5,mode=620? 0 0
sysfs?????????????????? /sys??????????????????? sysfs?? defaults??????? 0 0
proc??????????????????? /proc?????????????????? proc??? defaults??????? 0 0
[root@localhost ~]#
-n, --number(顯示行號)
????????????? number all output lines
[root@localhost ~]# cat -n /etc/issue
???? 1?Red Hat Enterprise? Server release 6.6 (Santiago)
???? 2?\m
???? 3?
-E, --show-ends(顯示結束符號$,windows結束符為$+回車)
????????????? display $ at end of each line
[root@localhost ~]# cat -E /etc/issue
Red Hat Enterprise? Server release 6.6 (Santiago)$
\m$
$
tac:倒敘顯示文本
NAME
?????? tac - concatenate and print files in reverse
[root@localhost ~]# cat /etc/issue
Red Hat Enterprise? Server release 6.6 (Santiago)
\m
[root@localhost ~]# tac /etc/issue
\m
Red Hat Enterprise? Server release 6.6 (Santiago)
more、less:分屏查看
more支持向后翻屏,翻到文章尾部后退出
less不會退出
head:輸出文件首部
NAME
?????? head - output the first part of files
[root@localhost ~]# head /etc/inittab
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
tail:輸出文件尾部
NAME
?????? tail - output the last part of files
[root@localhost ~]# tail /etc/inittab
# Default runlevel. The runlevels used are:
#?? 0 - halt (Do NOT set initdefault to this)
#?? 1 - Single user mode
#?? 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#?? 3 - Full multiuser mode
#?? 4 - unused
#?? 5 - X11
#?? 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
[root@localhost ~]#
-f, --follow[={name|descriptor}] (查看文件尾部后續追加內容)
????????????? output appended data as the file? grows;? -f,? --follow,? and? --follow=descriptor? are
????????????? equivalent
轉載于:https://blog.51cto.com/f1yinsky/1897101
總結
以上是生活随笔為你收集整理的linux常用命令-查看文本/cat,tac,more,less,head,tail的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: this
- 下一篇: 软件开发本质论——自然之路