处理/etc/fstab路径,使用sed命令取出其目录名和基名

[root@centos ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Jan 7 10:30:15 2022
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=f9141c97-8534-492b-bddb-36b2b72885d8 / xfs defaults 0 0
UUID=160fb4bd-c669-47e9-9c9d-22d2818a61e8 /boot xfs defaults 0 0
UUID=d631802d-99ac-45b0-89f6-8e477e1b4abf /data xfs defaults 0 0
UUID=c3cea76d-6b24-4bd5-8fad-2cd04c083f9a none swap defaults 0 0

/dev/vg0/mysql /mnt/mysql ext4 defaults 0 0
/dev/vg0/log /mnt/log xfs defaults 0 0
[root@centos ~]# echo /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@\1@p'
/etc
[root@centos ~]# echo /etc/fstab | sed -nr 's@^(.*)/([^/]+)/?$@\2@p'
fstab
[root@centos ~]#

 

 

 

posted @ 2022-01-29 23:01  LeeSin-  阅读(154)  评论(0编辑  收藏  举报