From 71d2bfce9a0c6bfdf41fb5021e312fe86ccd1a90 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Wed, 19 Oct 2022 00:02:18 +0800 Subject: [PATCH] doc: update `curl.md`. --- docs/curl.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/docs/curl.md b/docs/curl.md index 5cead24..4234d78 100644 --- a/docs/curl.md +++ b/docs/curl.md @@ -173,4 +173,56 @@ curl -s -w \ ```bash curl -o /dev/null --silent -Iw "%{http_code}" https://example.com/my.remote.tarball.gz ``` - \ No newline at end of file + + +### 正在下载文件 + + +```bash +curl https://example.com | \ +grep --only-matching 'src="[^"]*.[png]"' | \ +cut -d\" -f2 | \ +while read i; do curl https://example.com/"${i}" \ +-o "${i##*/}"; done +``` + +从站点下载所有 PNG 文件(使用GNU grep) + +### 下载文件,保存文件而不更改其名称 + + +```bash +curl --remote-name "https://example.com/linux-distro.iso" +``` + +重命名文件 + +```bash +curl --remote-name "http://example.com/index.html" --output foo.html +``` + +### 继续部分下载 + + +```bash +curl --remote-name --continue-at - "https://example.com/linux-distro.iso" +``` + + +### 从多个域下载文件 + + +```bash +curl "https://www.{example,w3,iana}.org/index.html" --output "file_#1.html" +``` + + +### 下载一系列文件 + + +```bash +curl "https://{foo,bar}.com/file_[1-4].webp" --output "#1_#2.webp" +``` + + +下载一系列文件(输出`foo_file1.webp`、`foo_file2.webp…bar_file1_webp`等)