次sed
のコマンドを使用して、特定の形式のファイル名を表示します。
ls -1 *|sed 's/^\(.*\).png/\1\/\1,/g'
BOH_Contour.png
名前が2つのファイルがあり、次のものをBOV_Web.png
取得する場合
BOH_Contour/BOH_Contour,
BOV_Web/BOV_Web,
_
これで、この結果の2番目の部分のすべての内容を削除します。
BOH_Contour/BOHContour,
BOV_Web/BOVWeb,
どうすればいいですか?
ベストアンサー1
一般的に使用する場所は次のとおりです。捕まえるスペース:
ls | sed '
/\.png$/!d; # discard everything but lines ending in .png
s///; # remove that .png
h; # store on the hold space
s/_//g; # remove underscores
H; # append (with a newline) to the hold space
g; # retrieve that hold space
s|\n|/|; # substitute the newline with a /
s/$/,/; # add that extra comma.'