UUID=89ec9224-65c7-4461-9350-9d5e016d016c / xfs defaults 0 0
#
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
# Accessible filesystems, by reference, are maintained under '/dev/disk'
#
# Created by anaconda on Thu Jul 21 12:06:23 2016
# /etc/fstab
#
# This is three line.
# This is two line.
# This is one line.
[root@CentOS7 Packages]#
3.显示文件的最后两行内容
[root@CentOS7 Packages]# nl /etc/fstab | sed '$!N;$!D'
13UUID=e70e4b66-c716-4d00-a483-4771fea4a9c1 /testdir xfs defaults 0 0
14UUID=6cfc5ecc-625f-4a4c-936f-95e4bab93dd6 swap swap defaults 0 0
[root@CentOS7 Packages]#
4.将文件的空白行删除,并且在每行后面添加空白行
[root@CentOS7 ~]# sed '/^$/d;G' /etc/fstab
# This is one line.
# This is two line.
# This is three line.
#
# /etc/fstab
# Created by anaconda on Thu Jul 21 12:06:23 2016
#
# 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
#