SHELL小知识SHELL小知识SHELL小知识SHELL小知识SHELL小知识SHELL小知识

1. #此处1表示原文件的最后一行;-i.bak会将源文件变成fstab.bak
[root@k8s-master ~]# more /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Apr  6 16:56:57 2021
#
# 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=dc059168-52c0-4287-b877-1385b235bebc /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0

[root@k8s-master ~]# 
[root@k8s-master ~]# sed -i.bak  ‘/swap/ s/^\(.*\)$/#\1/g‘ /etc/fstab 
[root@k8s-master ~]# more /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Apr  6 16:56:57 2021
#
# 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
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=dc059168-52c0-4287-b877-1385b235bebc /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
#/dev/mapper/centos-swap swap                    swap    defaults        0 0

[root@k8s-master ~]# 

 

SHELL小知识SHELL小知识SHELL小知识SHELL小知识SHELL小知识SHELL小知识

上一篇:Linux 函数 - 第13天 - 20210413


下一篇:多进程报错