linux curl命令详解及实例分享

2019-10-14 13:24:44丽君

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100   101  100   101    0     0    105      0 --:--:-- --:--:-- --:--:--     0

  [root@krlcgcms01 mytest]# curl -r 100-200 -o img.part2 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100   101  100   101    0     0     57      0  0:00:01  0:00:01 --:--:--     0

  [root@krlcgcms01 mytest]# curl -r 200- -o img.part3 //www.jb51.net/wp-

  content/uploads/2010/09/compare_varnish.jpg

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  100  104k  100  104k    0     0  52793      0  0:00:02  0:00:02 --:--:-- 88961

  [root@krlcgcms01 mytest]# ls |grep part | xargs du -sh

  4.0K    one.part1

  112K    three.part3

  4.0K    two.part2

  用的时候,把他们cat一下就OK了,cat img.part* >img.jpg

  12,不会显示下载进度信息

  [root@krlcgcms01 mytest]# curl -s -o aaa.jpg

  13,显示下载进度条

  [root@krlcgcms01 mytest]# curl -# -O

  ######################################################################## 100.0%

  14,通过ftp下载文件

  [zhangy@BlackGhost ~]$ curl -u 用户名:密码 -O //www.jb51.net/demo/curtain/bbstudy_files/style.css

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

  Dload  Upload   Total   Spent    Left  Speed

  101  1934  101  1934    0     0   3184      0 --:--:-- --:--:-- --:--:--  7136

  [zhangy@BlackGhost ~]$ curl -u 用户名:密码 -O //www.jb51.net/demo/curtain/bbstudy_files/style.css

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current