页面“每天一命令之curl”与“每天一命令之du”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
docker>Evan
 
第1行: 第1行:
=常用参数=
+
 
 +
== du正文==
 
<pre>
 
<pre>
-L, --location      Follow redirects 进行强制重定向
+
0. name
    --location-trusted Like --location, and send auth to other hosts
+
NAME
    --login-options <options> Server login options
+
      du - estimate file space usage
    --mail-auth <address> Originator address of the original email
 
    --mail-from <address> Mail from this address
 
    --mail-rcpt <address> Mail to this address
 
  
 +
1.命令格式:
 +
  du [选项][文件]
 +
 
 +
SYNOPSIS
 +
      du [OPTION]... [FILE]...
 +
      du [OPTION]... --files0-from=F
  
-o, --output <file> Write to file instead of stdout
+
2. 命令功能
-o:将文件保存为命令行中指定的文件名的文件中
+
DESCRIPTION
 +
      显示每个文件和目录的磁盘使用空间
 +
      Summarize disk usage of the set of FILEs, recursively for directories.
  
-O:使用URL中默认的文件名保存文件到本地
+
      Mandatory arguments to long options are mandatory for short options too.
  
举个栗子
+
3. 命令参数
curl -L linux.net/lnmp.sh -o 1.sh
+
-a或-all  显示目录中个别文件的大小。 
把lnmp.sh 下载回来 并重命令为1.sh
+
-s或--summarize  仅显示总计,只列出最后加总的值。
 +
-h或--human-readable  以K,M,G为单位,提高信息的可读性。
  
 +
--exclude=PATTERN 非常好用的参数 排除 取反 ,记得不是一个路径,而是要用相对路径
 +
du -sh /*  --exclude=data --exclude=data1 --exclude=data2 --exclude=data3 --exclude=proc
  
 +
常用就是 du -sh
 +
</pre>
  
指令:curl
+
==du -sh 排序==
在linux中curl是一个利用URL规则在命令行下工作的文件传输工具,可以说是一款很强大的http命令行工具。它支持文件的上传和下载,是综合传输工具,但按传统,习惯称url为下载工具。
+
<pre>
 
+
1. sort --help 可是有
 
+
-h, --human-numeric-sort 使用易读性数字(例如: 2K 1G) 参数的排序不好,
语法:# curl [option] [url]
+
du -h | sort -h
 
 
 
 
常见参数:
 
-A/--user-agent <string>        设置用户代理发送给服务器
 
-b/--cookie <name=string/file>  cookie字符串或文件读取位置
 
-c/--cookie-jar <file>         操作结束后把cookie写入到这个文件中
 
-C/--continue-at <offset>      断点续转
 
-D/--dump-header <file>        把header信息写入到该文件中
 
-e/--referer                    来源网址
 
-f/--fail                      连接失败时不显示http错误
 
-o/--output                    把输出写到该文件中
 
-O/--remote-name                把输出写到该文件中,保留远程文件的文件名
 
-r/--range <range>              检索来自HTTP/1.1或FTP服务器字节范围
 
-s/--silent                    静音模式。不输出任何东西
 
-T/--upload-file <file>        上传文件
 
-u/--user <user[:password]>    设置服务器的用户和密码
 
-w/--write-out [format]        什么输出完成后
 
-x/--proxy <host[:port]>        在给定的端口上使用HTTP代理
 
-#/--progress-bar              用进度条显示当前的传送状态
 
  
 +
2.du -s * | sort -k 1 -g | awk '{print $2}' | xargs du -sh {}
  
 +
3.
 +
du -sk * | sort -n | #以 K 字节的方式排序
  
 +
4.good
 +
du -s * | sort -nr|head  #我一般用这个排序
 +
</pre>
  
 +
==在du命令里如何排除其它目录==
 +
<pre>
 +
--exclude=PATTERN 不是一个路径
  
 +
du -sh /*  --exclude=data --exclude=data1  --exclude=proc
 +
</pre>
  
 +
==参考==
  
  
用curl的内置option就好,存下http的结果,用这个option: -o
+
[http://www.cnblogs.com/peida/archive/2012/12/10/2810755.html 每天一个linux命令(34):du 命令]
  
curl -o page.html http://www.yahoo.com
 
  
大写的O,这么用:这样,就可以按照服务器上的文件名,自动存在本地了
+
[http://blog.sina.com.cn/s/blog_48e13c9e0102vezm.html Linux按文件夹大小排序命令 du -k | sort -rn ]
curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen1.JPG
 
 
 
 
 
访问不到?肯定是你的proxy没有设定了。
 
使用curl的时候,用这个option可以指定http访问所使用的proxy服务器及其端口: -x
 
curl -x 123.45.67.89:1080 -o page.html http://www.yahoo.com
 
 
 
 
 
下载
 
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
 
 
 
 
 
其它例子本身就是一个sh脚本 哈哈 写得不错
 
https://test.docker.com/
 
curl -fsSL https://test.docker.com/ | bash
 
 
 
curl -fsSL https://test.com/lnmp.sh | bash
 
 
 
-f/--fail                      连接失败时不显示http错误
 
 
 
-s/--silent                    静音模式。不输出任何东西
 
 
 
-S, --show-error    Show error. With -s, make curl show errors when they occur
 
 
 
-L, --location      Follow redirects (H)
 
 
 
or
 
wget http://xxx/xxx.sh -O- | bash
 
 
 
</pre>
 
 
 
=指定ip访问url=
 
<pre>指定ip访问url
 
curl -H 'Host:a.com' http://10.12.20.21
 
 
 
</pre>
 
  
=see also=
+
[http://dengxi.blog.51cto.com/4804263/1701438 du和sort 命令的使用和技巧]
https://www.cnblogs.com/gbyukg/p/3326825.html
 
  
http://www.21andy.com/new/20080602/1154.html
+
Linux du命令查看文件夹大小并按降序排列
http://doiido.blog.51cto.com/5503054/1564631
+
http://m.jb51.net/article/74737.htm
https://www-31.ibm.com/support/techdocs/cn/faqhtmlfaq/2311073I23001.htm  
 
  
[[category:shell]][[category:ops]][[category:linux]]
+
将du的输出按文件大小排序
 +
https://blog.lilydjwg.me/posts/18368.html
 +
[[category:ops]] [[category:shell]][[category:linux]]

2019年2月14日 (四) 13:34的版本

du正文

0. name
NAME
       du - estimate file space usage

1.命令格式:
  du [选项][文件]
  
SYNOPSIS
       du [OPTION]... [FILE]...
       du [OPTION]... --files0-from=F

2. 命令功能
DESCRIPTION
       显示每个文件和目录的磁盘使用空间
       Summarize disk usage of the set of FILEs, recursively for directories.

       Mandatory arguments to long options are mandatory for short options too.

3. 命令参数
-a或-all  显示目录中个别文件的大小。  
-s或--summarize  仅显示总计,只列出最后加总的值。
-h或--human-readable  以K,M,G为单位,提高信息的可读性。

--exclude=PATTERN 非常好用的参数 排除 取反 ,记得不是一个路径,而是要用相对路径 
du -sh /*  --exclude=data --exclude=data1 --exclude=data2 --exclude=data3 --exclude=proc

常用就是 du -sh 

du -sh 排序

1. sort --help 可是有 
-h, --human-numeric-sort 使用易读性数字(例如: 2K 1G) 参数的排序不好,
du -h | sort -h

2.du -s * | sort -k 1 -g | awk '{print $2}' | xargs du -sh {}

3. 
du -sk * | sort -n | #以 K 字节的方式排序

4.good
du -s * | sort -nr|head  #我一般用这个排序

在du命令里如何排除其它目录

--exclude=PATTERN 不是一个路径

du -sh /*  --exclude=data --exclude=data1  --exclude=proc

参考

每天一个linux命令(34):du 命令


Linux按文件夹大小排序命令 du -k | sort -rn

du和sort 命令的使用和技巧

Linux du命令查看文件夹大小并按降序排列 http://m.jb51.net/article/74737.htm

将du的输出按文件大小排序 https://blog.lilydjwg.me/posts/18368.html