そのため、ランニングはxargs cd機能しません。

そのため、ランニングはxargs cd機能しません。

ファイルを見つけて、そのファイルを含むディレクトリに移動したいと思います。努力しましたが、find /media/storage -name "Fedora" | xargs cdもちろんis not a directoryミスもしました。

1行のコマンドで親ディレクトリにどのように入力できますか?

ベストアンサー1

少なくともGNUがある場合は、次のようにディレクトリを取得findできます。-printf '%h'

       %h     Leading directories of file's name (all but the last ele‐
              ment).  If the file name contains no slashes (since it is
              in  the  current  directory)  the %h specifier expands to
              ".".

だからあなたはおそらく行うことができます

cd "$(find /media/storage -name "Fedora" -printf '%h' -quit)"

複数のファイルが一致する場合は、-quit複数の引数を使用しないでください。cd

おすすめ記事