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 "^[^/]+"

  

上一篇:create-react-app 工程,如何修改react端口号


下一篇:新建虚拟环境失败