我使用以下sed命令显示具有特定表单的文件名:
ls -1 *|sed 's/^\(.*\).png/\1\/\1,/g'如果我有两个名为BOH_Contour.png和BOV_Web.png的文件,我将获得
BOH_Contour/BOH_Contour,
BOV_Web/BOV_Web,现在,我希望删除这个结果的第二部分中的所有_,并获得
BOH_Contour/BOHContour,
BOV_Web/BOVWeb,我该怎么做?
发布于 2015-01-20 13:23:42
可能有助于:
ls -1 *|sed 's/^\(.*\).png/\1\/\1,/g ; : 1 ; s|_\([^/]*$\)|\1|; t 1'或者如果只有一个文件名中的_
ls -1 *|sed 's/^\(.*\).png/\1\/\1,/g ; s|_||2'https://unix.stackexchange.com/questions/180053
复制相似问题