Find と sed は出力を返しません。

Find と sed は出力を返しません。

ディレクトリを検索していますが、私の場合は最後のディレクトリのみが返されますxyz。その後、sedを使用してそのディレクトリ内の他のすべての拡張を置き換えることでこれを達成したいと思います。

私が試したこと:

find **/macml/xyz -maxdepth 1 -not -path '*__*' -type d

#Returns the following
macml/xyz

その後、sedと組み合わせます。

find **/macml/xyz -maxdepth 1 -not -path '*__*' -type d -exec sed -E "s|^[macml\/]*||g" {} \+ & 

何も返しません。

予想出力:

xyz

ベストアンサー1

試行中のコマンドから予想される「xyz」出力を取得するには、次のコマンドを使用できます。

find /macml/xyz -maxdepth 1 -not -path '__' -type d -exec bash -c 'echo "${0##*/}"' {} + & 

このコマンドは、パスの「macml /」部分を削除して「xyz」ディレクトリを返します。

おすすめ記事