![컬: 이름은 같지만 특정 경로 디렉터리를 정의하는 파일을 다운로드하려면 "-O"를 사용하세요.](https://linux55.com/image/212552/%EC%BB%AC%3A%20%EC%9D%B4%EB%A6%84%EC%9D%80%20%EA%B0%99%EC%A7%80%EB%A7%8C%20%ED%8A%B9%EC%A0%95%20%EA%B2%BD%EB%A1%9C%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EB%A5%BC%20%EC%A0%95%EC%9D%98%ED%95%98%EB%8A%94%20%ED%8C%8C%EC%9D%BC%EC%9D%84%20%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C%ED%95%98%EB%A0%A4%EB%A9%B4%20%22-O%22%EB%A5%BC%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%84%B8%EC%9A%94..png)
할 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.