ファイルを見つけて、そのファイルを含むディレクトリに移動したいと思います。努力しましたが、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