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
#在匹配的行之前添加hello world字段。
# sed '/^\//i \hello world' /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 24 02:20:51 2017
#
# 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
#
hello world
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=2020ea71-49cf-488e-bd6c-de72a001082b /boot ext4 defaults 1 2
hello world
/dev/mapper/VolGroup-lv_swap 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
匹配在大写字母开头的行之后添加二行,第一行hello,第二行second。注释:匹配大写字母以[[:upper:]]
# sed '/^[[:upper:]]/a \hello \nsecond' /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 24 02:20:51 2017
#
# 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/VolGroup-lv_root / ext4 defaults 1 1
UUID=2020ea71-49cf-488e-bd6c-de72a001082b /boot ext4 defaults 1 2
hello
second
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0