カール:名前は同じですが、特定のパスディレクトリを定義するファイルをダウンロードするには、「-O」を使用します。

カール:名前は同じですが、特定のパスディレクトリを定義するファイルをダウンロードするには、「-O」を使用します。

できるcurl

curl http://somedomain.com/originalfilename.tar.gz -o newfilename.tar.gz
curl http://somedomain.com/originalfilename.tar.gz -o /other/path/newfilename.tar.gz

したがって、-oダウンロードするファイルの名前を変更したり、ダウンロードする別のパスディレクトリを定義したりすることもできます。

これで、同じファイル名を保持するために使用する必要があります。-O

curl http://somedomain.com/originalfilename.tar.gz -O

だからファイルがダウンロードされましたoriginalfilename.tar.gz

質問

  • 名前を保持するファイルをダウンロードする方法(-Oそしてダウンロードするディレクトリを定義しますか?

それはまるで

curl http://somedomain.com/originalfilename.tar.gz -O <download to /some/path>

したがって、シェルスクリプトの場合、スクリプトはどこでも実行できます。originalfilename.tar.gz明示的にファイルをダウンロードしたいです。/some/path

ベストアンサー1

このオプションを使用して、作成する文書のディレクトリパスを指定できます--output-dir

それは、

curl -O --output-dir /some/path "$URL"

curlマニュアルから:

--output-dir <dir>

       This option specifies the directory in which files should be
       stored, when --remote-name or --output are used.

       The given output directory is used for all URLs and output
       options on the command line, up until the first -:, --next.

       If the specified target directory does not exist, the operation
       will fail unless --create-dirs is also used.

       If this option is used multiple times, the last specified
       directory will be used.

       Example:
        curl --output-dir "tmp" -O https://example.com

       See also -O, --remote-name and -J, --remote-header-name. Added
       in 7.73.0.

おすすめ記事