linux系统使用grep命令提取文件的基名或者路径名
效果等于~]#dirname /etc/sysconfig/network-scripts/ifcfg-ens33
echo "/etc/sysconfig/network-scripts/ifcfg-ens33"|grep -o -E "(^/([^/]+/)*[^[:space:]])|^/"|grep -o -E "^/([^/]+/)*"|grep -o -E "(/[^/]+)+|^/"
效果等于:~]#basename /etc/sysconfig/network-scripts/ifcfg-ens33
echo "/etc/sysconfig/network-scripts/ifcfg-ens33"|grep -o -E "[^/]+/?$"|grep -o -E "^[^/]+"