deploy: bd7b9fb154
This commit is contained in:
parent
d857756f11
commit
f9a2d92f6e
107
c/ab.html
107
c/ab.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,ab,Apache服务器的性能测试工具">
|
||||
<title>ab 命令,Linux ab 命令详解:Apache服务器的性能测试工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159197896">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219283">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,14 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>ab命令</strong> 是一个测试你 Apache http 服务器的工具,你可以通过这个工具,指定一个单位时间内向 apache 发出的请求数量来看看你的 Apache 和机器配合的性能如何。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">ab <span class="token punctuation">[</span> -A auth-username:password <span class="token punctuation">]</span> <span class="token punctuation">[</span> -c concurrency <span class="token punctuation">]</span> <span class="token punctuation">[</span> -C cookie-name<span class="token operator">=</span>value
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ab [ -A auth-username:password ] [ -c concurrency ] [ -C cookie-name=value
|
||||
] [ -d ] [ -e csv-file ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [
|
||||
-i ] [ -k ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-user‐
|
||||
name:password ] [ -q ] [ -s ] [ -S ] [ -t timelimit ] [ -T content-type ]
|
||||
[ -v verbosity] [ -V ] [ -w ] [ -x <table>-attributes ] [ -X proxy[:port]
|
||||
] [ -y <tr>-attributes ] [ -z <td>-attributes ] [http://]host‐
|
||||
name[:port]/path
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ab <span class="token punctuation">[</span> -A auth-username:password <span class="token punctuation">]</span> <span class="token punctuation">[</span> -c concurrency <span class="token punctuation">]</span> <span class="token punctuation">[</span> -C cookie-name<span class="token operator">=</span>value
|
||||
<span class="token punctuation">]</span> <span class="token punctuation">[</span> -d <span class="token punctuation">]</span> <span class="token punctuation">[</span> -e csv-file <span class="token punctuation">]</span> <span class="token punctuation">[</span> -g gnuplot-file <span class="token punctuation">]</span> <span class="token punctuation">[</span> -h <span class="token punctuation">]</span> <span class="token punctuation">[</span> -H custom-header <span class="token punctuation">]</span> <span class="token punctuation">[</span>
|
||||
-i <span class="token punctuation">]</span> <span class="token punctuation">[</span> -k <span class="token punctuation">]</span> <span class="token punctuation">[</span> -n requests <span class="token punctuation">]</span> <span class="token punctuation">[</span> -p POST-file <span class="token punctuation">]</span> <span class="token punctuation">[</span> -P proxy-auth-user‐
|
||||
name:password <span class="token punctuation">]</span> <span class="token punctuation">[</span> -q <span class="token punctuation">]</span> <span class="token punctuation">[</span> -s <span class="token punctuation">]</span> <span class="token punctuation">[</span> -S <span class="token punctuation">]</span> <span class="token punctuation">[</span> -t timelimit <span class="token punctuation">]</span> <span class="token punctuation">[</span> -T content-type <span class="token punctuation">]</span>
|
||||
|
|
@ -66,7 +73,97 @@ name:password <span class="token punctuation">]</span> <span class="token punctu
|
|||
name<span class="token punctuation">[</span>:port<span class="token punctuation">]</span>/path
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-A auth-username:password
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-A auth-username:password
|
||||
# 支持基本的验证证书,用户名和密码之间使用"冒号" :
|
||||
# 分隔开,ab将以明文方式传送过去.不管服务器是不是需要
|
||||
# ,也就是说你的服务器需要支持401认证.
|
||||
|
||||
-c concurrency
|
||||
# 同时向服务器端发送的请求数目,默认状态下是一次 只执行一个http请求.
|
||||
|
||||
-C cookie-name=value
|
||||
# Add a Cookie: line to the request. The argument is typically in the
|
||||
# form of a name=value pair. This field is repeatable.
|
||||
|
||||
-d # Do not display the "percentage served within XX [ms] table".
|
||||
# (legacy support).
|
||||
|
||||
-e csv-file
|
||||
# Write a Comma separated value (CSV) file which contains for each
|
||||
# percentage (from 1% to 100%) the time (in milli seconds) it took to
|
||||
# serve that percentage of the requests. This is usually more useful
|
||||
# than the 'gnuplot' file; as the results are already 'binned'.
|
||||
|
||||
-g gnuplot-file
|
||||
# Write all measured values out as a 'gnuplot' or TSV (Tab separate
|
||||
# values) file. This file can easily be imported into packages like
|
||||
# Gnuplot, IDL, Mathematica, Igor or even Excell. The labels are on
|
||||
# the first line of the file.
|
||||
-h # 显示使用说明
|
||||
-H custom-header
|
||||
# 向请求包追加附加的标题字串.此参数应该是有效的标题 行(header
|
||||
# line)形式,通常使用冒号":"来分隔有效配对 (valid pair)例如 'Accept-
|
||||
# Encoding: zip/zop;8 bit';
|
||||
|
||||
-i # 使用一个 http 头(HEAD) 来替换 GET方法.不可以掺入POST 方法
|
||||
|
||||
-k # 允许http KeepAlive ;也就是说执行多个请求在一个 http
|
||||
# 会话当中,默认是不允许的也就是no KeepAlive啦;)
|
||||
|
||||
-n requests
|
||||
# 执行一次测试会话的时候所发出的请求数目,默认是执行一个单一的请求
|
||||
# 当然了这样的测试结果也就没什么意义了
|
||||
|
||||
-p POST-file
|
||||
# 测试程序也就是ab,将向Apache server发送带有HTTP POST 的请求.
|
||||
|
||||
-P proxy-auth-username:password
|
||||
# 当需要通过代理测试一台 HTTP 服务器的时候而你的代理
|
||||
# 又需要用户名密码验证,这时你可以使用这个选项,同样
|
||||
# 用户名与密码之间使用冒号":"分隔开,ab将之以明文的方式
|
||||
# 发送出去,当然,前提是你的代理是处于407认证状态的
|
||||
|
||||
-q # When processing more than 150 requests, ab outputs a progress count
|
||||
# on stderr every 10% or 100 requests or so. The -q flag will sup‐
|
||||
# press these messages.
|
||||
|
||||
-s # When compiled in (ab -h will show you) use the SSL protected https
|
||||
# rather than the http protocol. This feature is experimental and
|
||||
# very rudimentary. You probably do not want to use it.
|
||||
|
||||
-S # Do not display the median and standard deviation values, nor dis‐
|
||||
# play the warning/error messages when the average and median are
|
||||
# more than one or two times the standard deviation apart. And de‐
|
||||
# fault to the min/avg/max values. (legacy support).
|
||||
|
||||
-t timelimit
|
||||
# 设置测试的时间的长短,使用这个选项ab将自动设置
|
||||
# 测试请求会话数目为50000,然后以你设置的时间为
|
||||
# 固定周期.默认状态下是没有时限的,也就是直到完成
|
||||
# 你所设置的请求数目为止.
|
||||
|
||||
-T content-type
|
||||
# 内容类型标头,使用在POST数据的时候.
|
||||
|
||||
-v verbosity
|
||||
# 设置冗余级别,4级打印出每个请求标头的详细信息,
|
||||
# 3级打印出回应代码(例如,404,200),2级打印出警告 信息和指示消息
|
||||
|
||||
-V # 显示版本号并且退出
|
||||
-w # 打印输出结果到HTML表中. 默认的表是两列n行白底黑框
|
||||
|
||||
-x <table>-attributes
|
||||
# 使用字串来描述表的属性,该属性字串应该插入到<table 这里 >
|
||||
|
||||
-X proxy[:port]
|
||||
# Use a proxy server for the requests.
|
||||
|
||||
-y <tr>-attributes
|
||||
# 用于生成html表格每行的属性名 (<tr>)
|
||||
|
||||
-z <td>-attributes
|
||||
# 用于生成html表格每列的属性名 (<td>)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-A auth-username:password
|
||||
<span class="token comment"># 支持基本的验证证书,用户名和密码之间使用"冒号" :</span>
|
||||
<span class="token comment"># 分隔开,ab将以明文方式传送过去.不管服务器是不是需要</span>
|
||||
<span class="token comment"># ,也就是说你的服务器需要支持401认证.</span>
|
||||
|
|
@ -184,7 +281,7 @@ name<span class="token punctuation">[</span>:port<span class="token punctuation"
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159197897"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159197897"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219284"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219284"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,accept,指示打印系统接受发往指定目标打印机的打印任务">
|
||||
<title>accept 命令,Linux accept 命令详解:指示打印系统接受发往指定目标打印机的打印任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159197907">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219293">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,14 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>accept命令</strong> 属于CUPS套件,用于指示打印系统接受发往指定目标打印机的打印任务。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre><code>accept(选项)(参数)
|
||||
<pre><div onclick="copied(this)" data-code="accept(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>accept(选项)(参数)
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre><code>-E:当连接到服务器时强制加密;
|
||||
<pre><div onclick="copied(this)" data-code="-E:当连接到服务器时强制加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-h:指定连接服务器名和端口号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>-E:当连接到服务器时强制加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-h:指定连接服务器名和端口号。
|
||||
</code></pre>
|
||||
|
|
@ -91,7 +95,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159197908"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159197908"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219294"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219294"></script>
|
||||
</body>
|
||||
</html>
|
||||
47
c/ack.html
47
c/ack.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,ack,比grep好用的文本搜索工具">
|
||||
<title>ack 命令,Linux ack 命令详解:比grep好用的文本搜索工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159197953">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219334">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,14 +55,20 @@
|
|||
<h1 id="ack"><a class="anchor" aria-hidden="true" tabindex="-1" href="#ack"><span class="octicon octicon-link"></span></a>ack</h1>
|
||||
<p>比grep好用的文本搜索工具</p>
|
||||
<h2 id="安装"><a class="anchor" aria-hidden="true" tabindex="-1" href="#安装"><span class="octicon octicon-link"></span></a>安装</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># ubuntu下要安装ack-grep,因为在debian系中,ack这个名字被其他的软件占用了。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# ubuntu下要安装ack-grep,因为在debian系中,ack这个名字被其他的软件占用了。
|
||||
sudo apt-get install ack-grep
|
||||
# alpine Linux-apk软件包管理器 安装 ack
|
||||
apk install ack
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># ubuntu下要安装ack-grep,因为在debian系中,ack这个名字被其他的软件占用了。</span>
|
||||
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> ack-grep
|
||||
<span class="token comment"># alpine Linux-apk软件包管理器 安装 ack</span>
|
||||
apk <span class="token function">install</span> ack
|
||||
</code></pre>
|
||||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<p>这些参数在linux上的适用频率是相当高的,尤其是你用vim做为IDE的话</p>
|
||||
<pre class="language-shell"><code class="language-shell">-c<span class="token punctuation">(</span>统计<span class="token punctuation">)</span>/ -i<span class="token punctuation">(</span>忽略大小<span class="token punctuation">)</span>/ -h<span class="token punctuation">(</span>不显示名称<span class="token punctuation">)</span>/
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c(统计)/ -i(忽略大小)/ -h(不显示名称)/
|
||||
-l(只显文件名)/ -n(加行号)/ -v(显示不匹配)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c<span class="token punctuation">(</span>统计<span class="token punctuation">)</span>/ -i<span class="token punctuation">(</span>忽略大小<span class="token punctuation">)</span>/ -h<span class="token punctuation">(</span>不显示名称<span class="token punctuation">)</span>/
|
||||
-l<span class="token punctuation">(</span>只显文件名<span class="token punctuation">)</span>/ -n<span class="token punctuation">(</span>加行号<span class="token punctuation">)</span>/ -v<span class="token punctuation">(</span>显示不匹配<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h2 id="特点"><a class="anchor" aria-hidden="true" tabindex="-1" href="#特点"><span class="octicon octicon-link"></span></a>特点</h2>
|
||||
|
|
@ -80,13 +86,21 @@ apk <span class="token function">install</span> ack
|
|||
<p>Searching 代码搜索<br>Search output 搜索结果处理<br>File presentation 文件展示<br>File finding 文件查找<br>File inclusion/exclusion 文件过滤</p>
|
||||
</blockquote>
|
||||
<p>grep常用操作</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">grep</span> -r <span class="token string">'hello_world'</span> <span class="token comment"># 简单用法</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="grep -r 'hello_world' # 简单用法
|
||||
grep '^hello_world' . # 简单正则
|
||||
ls -l | grep .py # 管道用法
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">grep</span> -r <span class="token string">'hello_world'</span> <span class="token comment"># 简单用法</span>
|
||||
<span class="token function">grep</span> <span class="token string">'^hello_world'</span> <span class="token builtin class-name">.</span> <span class="token comment"># 简单正则</span>
|
||||
<span class="token function">ls</span> -l <span class="token operator">|</span> <span class="token function">grep</span> .py <span class="token comment"># 管道用法</span>
|
||||
</code></pre>
|
||||
<h3 id="searching"><a class="anchor" aria-hidden="true" tabindex="-1" href="#searching"><span class="octicon octicon-link"></span></a>Searching</h3>
|
||||
<p>简单的文本搜索,默认是递归的。</p>
|
||||
<pre><code>ack-grep hello
|
||||
<pre><div onclick="copied(this)" data-code="ack-grep hello
|
||||
ack-grep -i hello
|
||||
ack-grep -v hello
|
||||
ack-grep -w hello
|
||||
ack-grep -Q 'hello*'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>ack-grep hello
|
||||
ack-grep -i hello
|
||||
ack-grep -v hello
|
||||
ack-grep -w hello
|
||||
|
|
@ -94,25 +108,36 @@ ack-grep -Q 'hello*'
|
|||
</code></pre>
|
||||
<h3 id="search-file"><a class="anchor" aria-hidden="true" tabindex="-1" href="#search-file"><span class="octicon octicon-link"></span></a>Search File</h3>
|
||||
<p>对搜索结果进行处理,比如只显示一个文件的一个匹配项,或者xxx</p>
|
||||
<pre class="language-shell"><code class="language-shell">ack-grep --line<span class="token operator">=</span><span class="token number">1</span> <span class="token comment"># 输出所有文件第二行</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ack-grep --line=1 # 输出所有文件第二行
|
||||
ack-grep -l 'hello' # 包含的文件名
|
||||
ack-grep -L 'print' # 非包含文件名
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ack-grep --line<span class="token operator">=</span><span class="token number">1</span> <span class="token comment"># 输出所有文件第二行</span>
|
||||
ack-grep -l <span class="token string">'hello'</span> <span class="token comment"># 包含的文件名</span>
|
||||
ack-grep -L <span class="token string">'print'</span> <span class="token comment"># 非包含文件名</span>
|
||||
</code></pre>
|
||||
<h3 id="file-presentation"><a class="anchor" aria-hidden="true" tabindex="-1" href="#file-presentation"><span class="octicon octicon-link"></span></a>File presentation</h3>
|
||||
<p>输出的结果是以什么方式展示呢,这个部分有几个参数可以练习下</p>
|
||||
<pre class="language-shell"><code class="language-shell">ack-grep hello --pager<span class="token operator">=</span><span class="token string">'less -R'</span> <span class="token comment"># 以less形式展示</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ack-grep hello --pager='less -R' # 以less形式展示
|
||||
ack-grep hello --noheading # 不在头上显示文件
|
||||
ack-grep hello --nocolor # 不对匹配字符着色
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ack-grep hello --pager<span class="token operator">=</span><span class="token string">'less -R'</span> <span class="token comment"># 以less形式展示</span>
|
||||
ack-grep hello --noheading <span class="token comment"># 不在头上显示文件</span>
|
||||
ack-grep hello --nocolor <span class="token comment"># 不对匹配字符着色</span>
|
||||
</code></pre>
|
||||
<h3 id="file-finding"><a class="anchor" aria-hidden="true" tabindex="-1" href="#file-finding"><span class="octicon octicon-link"></span></a>File finding</h3>
|
||||
<p>没错,它可以查找文件,以省去你要不断的结合find和grep的麻烦,虽然在linux的思想是一个工具做好一件事。</p>
|
||||
<pre class="language-shell"><code class="language-shell">ack-grep -f hello.py <span class="token comment"># 查找全匹配文件</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ack-grep -f hello.py # 查找全匹配文件
|
||||
ack-grep -g hello.py$ # 查找正则匹配文件
|
||||
ack-grep -g hello --sort-files # 查找然后排序
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ack-grep -f hello.py <span class="token comment"># 查找全匹配文件</span>
|
||||
ack-grep -g hello.py$ <span class="token comment"># 查找正则匹配文件</span>
|
||||
ack-grep -g hello --sort-files <span class="token comment"># 查找然后排序</span>
|
||||
</code></pre>
|
||||
<h3 id="file-inclusionexclusion"><a class="anchor" aria-hidden="true" tabindex="-1" href="#file-inclusionexclusion"><span class="octicon octicon-link"></span></a>File Inclusion/Exclusion</h3>
|
||||
<p>文件过滤,个人觉得这是一个很不错的功能。如果你曾经在搜索项目源码是不小心命中日志中的某个关键字的话,你会觉得这个有用。</p>
|
||||
<pre class="language-shell"><code class="language-shell">ack-grep --python hello <span class="token comment"># 查找所有python文件</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ack-grep --python hello # 查找所有python文件
|
||||
ack-grep -G hello.py$ hello # 查找匹配正则的文件
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ack-grep --python hello <span class="token comment"># 查找所有python文件</span>
|
||||
ack-grep -G hello.py$ hello <span class="token comment"># 查找匹配正则的文件</span>
|
||||
</code></pre>
|
||||
<h2 id="参考资料"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参考资料"><span class="octicon octicon-link"></span></a>参考资料</h2>
|
||||
|
|
@ -144,7 +169,7 @@ ack-grep -G hello.py$ hello <span class="token comment"># 查找匹配正则
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159197954"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159197954"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219334"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219334"></script>
|
||||
</body>
|
||||
</html>
|
||||
51
c/alias.html
51
c/alias.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,alias,定义或显示别名。">
|
||||
<title>alias 命令,Linux alias 命令详解:定义或显示别名。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198004">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219378">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="alias"><a class="anchor" aria-hidden="true" tabindex="-1" href="#alias"><span class="octicon octicon-link"></span></a>alias</h1>
|
||||
<p>定义或显示别名。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">alias</span> <span class="token punctuation">[</span>-p<span class="token punctuation">]</span> <span class="token punctuation">[</span>name<span class="token punctuation">[</span><span class="token operator">=</span>value<span class="token punctuation">]</span> <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="alias [-p] [name[=value] ...]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">alias</span> <span class="token punctuation">[</span>-p<span class="token punctuation">]</span> <span class="token punctuation">[</span>name<span class="token punctuation">[</span><span class="token operator">=</span>value<span class="token punctuation">]</span> <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -66,7 +67,8 @@
|
|||
<li>显示全部已定义的别名。</li>
|
||||
</ul>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">-p:显示全部已定义的别名。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-p:显示全部已定义的别名。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-p:显示全部已定义的别名。
|
||||
</code></pre>
|
||||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<p>name(可选):指定要(定义、修改、显示)的别名。</p>
|
||||
|
|
@ -74,7 +76,18 @@
|
|||
<h3 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h3>
|
||||
<p>alias返回true除非您要显示的别名未定义。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 显示全部已定义的别名</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 显示全部已定义的别名
|
||||
alias
|
||||
alias -p
|
||||
|
||||
# 显示已定义的别名(假设当前环境存在以下别名)
|
||||
alias ls
|
||||
alias ls grep
|
||||
|
||||
# 定义或修改别名的值
|
||||
alias ls='ls --color=auto'
|
||||
alias ls='ls --color=never' grep='grep --color=never'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 显示全部已定义的别名</span>
|
||||
<span class="token builtin class-name">alias</span>
|
||||
<span class="token builtin class-name">alias</span> -p
|
||||
|
||||
|
|
@ -93,7 +106,10 @@
|
|||
<blockquote>
|
||||
<p>请注意,以下内容可能与您实际使用的系统有出入:</p>
|
||||
<p>在CentOS7下,这个文件是<code>/etc/bash.bashrc</code>。此外在CentOS7下,细看<code>~/.bashrc</code>文件,会发现有这样一段代码:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token keyword">if</span> <span class="token punctuation">[</span> -f ~/.bash_aliases <span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token keyword">if</span> <span class="token punctuation">[</span> -f ~/.bash_aliases <span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">then</span>
|
||||
<span class="token builtin class-name">.</span> ~/.bash_aliases
|
||||
<span class="token keyword">fi</span>
|
||||
</code></pre>
|
||||
|
|
@ -108,14 +124,31 @@
|
|||
<p>当您定义(修改)别名的值的时候,由于值的字符串有空格但您没有用<strong>单引号扩起</strong>,那么会导致严重的问题:</p>
|
||||
</li>
|
||||
</ul>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 为方便演示,删除全部别名</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 为方便演示,删除全部别名
|
||||
unalias -a
|
||||
# 没有用单引号扩起
|
||||
alias rm=rm -rf
|
||||
# 执行命令后报错 bash: alias: -rf: not found
|
||||
# 这时使用alias查看rm的别名时返回 alias rm='rm'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 为方便演示,删除全部别名</span>
|
||||
<span class="token builtin class-name">unalias</span> -a
|
||||
<span class="token comment"># 没有用单引号扩起</span>
|
||||
<span class="token builtin class-name">alias</span> <span class="token assign-left variable">rm</span><span class="token operator">=</span>rm -rf
|
||||
<span class="token comment"># 执行命令后报错 bash: alias: -rf: not found</span>
|
||||
<span class="token comment"># 这时使用alias查看rm的别名时返回 alias rm='rm'</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 更具有迷惑性的例子</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 更具有迷惑性的例子
|
||||
# 为方便演示,删除全部别名
|
||||
unalias -a
|
||||
# 仍然没有用单引号括起
|
||||
alias ls=ls --color=never
|
||||
# 执行命令后看起来没有报错
|
||||
|
||||
# 使用alias查看全部别名会发现运行结果如下:
|
||||
# alias --color=never
|
||||
# alias ls='ls'
|
||||
# alias处理时将它们看成了两组
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 更具有迷惑性的例子</span>
|
||||
<span class="token comment"># 为方便演示,删除全部别名</span>
|
||||
<span class="token builtin class-name">unalias</span> -a
|
||||
<span class="token comment"># 仍然没有用单引号括起</span>
|
||||
|
|
@ -181,7 +214,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198005"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198005"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219379"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219379"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apachectl,Apache服务器前端控制工具">
|
||||
<title>apachectl 命令,Linux apachectl 命令详解:Apache服务器前端控制工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198015">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219387">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>apachectl命令</strong> 是Apache的Web服务器前端控制工具,用以启动、关闭和重新启动Web服务器进程。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre><code>apachectl(参数)
|
||||
<pre><div onclick="copied(this)" data-code="apachectl(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>apachectl(参数)
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -95,7 +96,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198015"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198015"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219388"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219388"></script>
|
||||
</body>
|
||||
</html>
|
||||
112
c/apk.html
112
c/apk.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apk,Alpine Linux 下的包管理工具">
|
||||
<title>apk 命令,Linux apk 命令详解:Alpine Linux 下的包管理工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198042">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219415">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,13 @@
|
|||
<h1 id="apk"><a class="anchor" aria-hidden="true" tabindex="-1" href="#apk"><span class="octicon octicon-link"></span></a>apk</h1>
|
||||
<p>Alpine Linux 下的包管理工具</p>
|
||||
<h2 id="使用实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#使用实例"><span class="octicon octicon-link"></span></a>使用实例</h2>
|
||||
<pre class="language-shell"><code class="language-shell">apk <span class="token function">install</span> xxx
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apk install xxx
|
||||
apk search xxx # 支持正则
|
||||
apk info xxx # 查看包的详细信息
|
||||
apk show # list local package
|
||||
# 卸载并删除 包
|
||||
apk del openssh openntp vim
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apk <span class="token function">install</span> xxx
|
||||
apk search xxx <span class="token comment"># 支持正则</span>
|
||||
apk info xxx <span class="token comment"># 查看包的详细信息</span>
|
||||
apk show <span class="token comment"># list local package</span>
|
||||
|
|
@ -64,25 +70,115 @@ apk del openssh openntp <span class="token function">vim</span>
|
|||
</code></pre>
|
||||
<h3 id="升级"><a class="anchor" aria-hidden="true" tabindex="-1" href="#升级"><span class="octicon octicon-link"></span></a>升级</h3>
|
||||
<p>upgrade命令升级系统已安装的所以软件包(一般包括内核),当然也可指定仅升级部分软件包(通过-u或–upgrade选择指定)。</p>
|
||||
<pre class="language-shell"><code class="language-shell">apk update <span class="token comment"># 更新最新本地镜像源</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apk update # 更新最新本地镜像源
|
||||
apk upgrade # 升级软件
|
||||
apk add --upgrade busybox # 指定升级部分软件包
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apk update <span class="token comment"># 更新最新本地镜像源</span>
|
||||
apk upgrade <span class="token comment"># 升级软件</span>
|
||||
apk <span class="token function">add</span> --upgrade busybox <span class="token comment"># 指定升级部分软件包</span>
|
||||
</code></pre>
|
||||
<h3 id="搜索"><a class="anchor" aria-hidden="true" tabindex="-1" href="#搜索"><span class="octicon octicon-link"></span></a>搜索</h3>
|
||||
<pre class="language-shell"><code class="language-shell">apk search <span class="token comment"># 查找所以可用软件包</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apk search # 查找所以可用软件包
|
||||
apk search -v # 查找所以可用软件包及其描述内容
|
||||
apk search -v 'acf*' # 通过软件包名称查找软件包
|
||||
apk search -v -d 'docker' # 通过描述文件查找特定的软件包
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apk search <span class="token comment"># 查找所以可用软件包</span>
|
||||
apk search -v <span class="token comment"># 查找所以可用软件包及其描述内容</span>
|
||||
apk search -v <span class="token string">'acf*'</span> <span class="token comment"># 通过软件包名称查找软件包</span>
|
||||
apk search -v -d <span class="token string">'docker'</span> <span class="token comment"># 通过描述文件查找特定的软件包</span>
|
||||
</code></pre>
|
||||
<h3 id="查看包信息"><a class="anchor" aria-hidden="true" tabindex="-1" href="#查看包信息"><span class="octicon octicon-link"></span></a>查看包信息</h3>
|
||||
<p>info命令用于显示软件包的信息。</p>
|
||||
<pre class="language-shell"><code class="language-shell">apk info <span class="token comment"># 列出所有已安装的软件包</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apk info # 列出所有已安装的软件包
|
||||
apk info -a zlib # 显示完整的软件包信息
|
||||
apk info --who-owns /sbin/lbu # 显示指定文件属于的包
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apk info <span class="token comment"># 列出所有已安装的软件包</span>
|
||||
apk info -a zlib <span class="token comment"># 显示完整的软件包信息</span>
|
||||
apk info --who-owns /sbin/lbu <span class="token comment"># 显示指定文件属于的包</span>
|
||||
</code></pre>
|
||||
<h2 id="笔记"><a class="anchor" aria-hidden="true" tabindex="-1" href="#笔记"><span class="octicon octicon-link"></span></a>笔记</h2>
|
||||
<p>还是蛮喜欢 alpine 的,简单纯粹</p>
|
||||
<pre class="language-shell"><code class="language-shell">apk <span class="token function">add</span> iproute2 <span class="token comment"># ss vs netstat</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apk add iproute2 # ss vs netstat
|
||||
ss -ptl
|
||||
apk add drill # drill vs nslookup&dig
|
||||
|
||||
crond # 开启 cron 服务
|
||||
crontab -l -e
|
||||
|
||||
apk add xxx
|
||||
apk search -v xxx
|
||||
apk info -a xxx
|
||||
apk info
|
||||
echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
|
||||
apk update
|
||||
|
||||
# storage
|
||||
ibu # alpine local backup
|
||||
|
||||
# network
|
||||
echo "shortname" > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
/etc/hosts
|
||||
/etc/resolv.conf # conig DNS
|
||||
modprobe ipv6 # enable ipv6
|
||||
echo "ipv6" >> /etc/modules
|
||||
iface # config interface
|
||||
apk add iptables ip6tables iptables-doc
|
||||
/etc/init.d/networking restart # activate change
|
||||
apke add iputils # IPv6 traceroute
|
||||
traceroute6 ipv6.google.com
|
||||
awall # alpine wall
|
||||
# setup a openvpn server
|
||||
|
||||
# post-install
|
||||
/etc/apk/repositories
|
||||
apk add cherokee --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
|
||||
apk search -v --description 'NTP' # show description and search from description
|
||||
apk info -a zlib
|
||||
apk info -vv|sort
|
||||
apk info -r -R # require / depency
|
||||
apk version -v -l '<' # show available updates
|
||||
apk upgrade -U -a
|
||||
apk add -u xxx # update xxx
|
||||
|
||||
/etc/runlevels # runlevel
|
||||
apk add openrc # use openrc for init system
|
||||
rc-update add xxx # set to start on
|
||||
rc-service xxx start # equal -> /etc/init.d/xxx start
|
||||
rc-status
|
||||
|
||||
adduser xxx
|
||||
passwd xxx
|
||||
|
||||
apk add ansible # server
|
||||
ssh-keygen
|
||||
/etc/ansible/hosts
|
||||
apk add python # node
|
||||
ssh-copy-id
|
||||
|
||||
apk add man man-pages mdocml-apropos less less-doc
|
||||
export PAGER=less
|
||||
/etc/rc.conf # /etc/rc.conf -> funny character
|
||||
apk add bash bash-doc bash-completion # bash
|
||||
apk add util-linux pciutils usbutils coreutils binutils findutils grep # grep / awk
|
||||
apk add build-base gcc abuild binutils binutils-doc gcc-doc # compile
|
||||
apk add cmake cmake-doc extra-cmake-modules extra-cmake-modules-doc
|
||||
apk add ccache ccache-doc
|
||||
|
||||
apk add docker # docker
|
||||
rc-update add docker boot
|
||||
rc-service docker start
|
||||
apk add py-pip
|
||||
pip install docker-compose
|
||||
ln -s /usr/bin/docker-compose /usr/bin/doc
|
||||
|
||||
# application
|
||||
apk add openssh # ssh
|
||||
rc-update add sshd
|
||||
/etc/init.d/sshd start
|
||||
/etc/sshd_config
|
||||
apk add dropbear # another openssh implementation
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apk <span class="token function">add</span> iproute2 <span class="token comment"># ss vs netstat</span>
|
||||
ss -ptl
|
||||
apk <span class="token function">add</span> drill <span class="token comment"># drill vs nslookup&dig</span>
|
||||
|
||||
|
|
@ -188,7 +284,7 @@ apk <span class="token function">add</span> dropbear <span class="token comment"
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198043"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198043"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219416"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219416"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apropos,在 whatis 数据库中查找字符串">
|
||||
<title>apropos 命令,Linux apropos 命令详解:在 whatis 数据库中查找字符串 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198077">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219441">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,10 +58,25 @@
|
|||
<p><strong>apropos命令</strong> 在一些特定的包含系统命令的简短描述的数据库文件里查找关键字,然后把结果送到标准输出。 </p>
|
||||
<p>如果你不知道完成某个特定任务所需要命令的名称,可以使用一个关键字通过Linux apropos实用程序来搜索它。该实用程序可以搜索关键字并且显示所有包含匹配项的man页面的简短描述。另外,使用man实用程序和-k(关键字)选项,可以得到和用Linux apropos实用程序相同的结果(实际上是相同的命令)。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apropos</span> <span class="token punctuation">[</span>-dalhvV<span class="token punctuation">]</span> -e<span class="token operator">|</span>-<span class="token punctuation">[</span>w<span class="token operator">|</span>-r<span class="token punctuation">]</span> <span class="token punctuation">[</span>-s section<span class="token punctuation">]</span> <span class="token punctuation">[</span>-m system<span class="token punctuation">[</span>,<span class="token punctuation">..</span>.<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">[</span>-M path<span class="token punctuation">]</span> <span class="token punctuation">[</span>-L locale<span class="token punctuation">]</span> -C <span class="token punctuation">[</span>file<span class="token punctuation">]</span> keyword <span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apropos [-dalhvV] -e|-[w|-r] [-s section] [-m system[,...]] [-M path] [-L locale] -C [file] keyword ...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apropos</span> <span class="token punctuation">[</span>-dalhvV<span class="token punctuation">]</span> -e<span class="token operator">|</span>-<span class="token punctuation">[</span>w<span class="token operator">|</span>-r<span class="token punctuation">]</span> <span class="token punctuation">[</span>-s section<span class="token punctuation">]</span> <span class="token punctuation">[</span>-m system<span class="token punctuation">[</span>,<span class="token punctuation">..</span>.<span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">[</span>-M path<span class="token punctuation">]</span> <span class="token punctuation">[</span>-L locale<span class="token punctuation">]</span> -C <span class="token punctuation">[</span>file<span class="token punctuation">]</span> keyword <span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-d, --debug:输出调试信息。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-d, --debug:输出调试信息。
|
||||
-v, --verbose:输出详细的警告信息。
|
||||
-r, -- regex:将每个keyword作为正则表达式解释。这是默认行为。每个keyword将匹配手册页和描述。
|
||||
-w, --wildcard:将每个keyword作为shell样式的通配符解释。
|
||||
-e, --exact:每个keyword将精确匹配手册页名字和描述。
|
||||
-a, --and:只显示匹配所有keyword的手册页和描述。默认显示匹配任何keyword的项。
|
||||
-l, --long:不根据终端宽度缩减输出。
|
||||
-s section, --section section:只查找指定的手册section。
|
||||
-m system[,...], --systems=system[,...]:用于查找其它操作系统的手册页。
|
||||
-M path, --manpath=path:指定从其它以冒号分隔的手册页层次查找。默认使用$MANPATH环境变量。这个选项覆盖$MANPATH的内容。
|
||||
-L locale, --locale=locale:apropos调用C函数setlocale来得到当前本地化信息,包括$LC_MESSAGE和$LANG。使用该选项提供一个locale字符串来临时更改本地化信息。
|
||||
-C file, --config-file=file:使用这个用户配置文件而不是默认的~/.manpath。
|
||||
-h, --help:打印帮助信息并退出。
|
||||
-V, --version:打印版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-d, --debug:输出调试信息。
|
||||
-v, --verbose:输出详细的警告信息。
|
||||
-r, -- regex:将每个keyword作为正则表达式解释。这是默认行为。每个keyword将匹配手册页和描述。
|
||||
-w, --wildcard:将每个keyword作为shell样式的通配符解释。
|
||||
|
|
@ -79,7 +94,28 @@
|
|||
<h3 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h3>
|
||||
<p>返回0表示成功,1表示用法、语法或配置文件错误,2表示操作错误,16表示没有找到匹配的内容。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># man -k who</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# man -k who
|
||||
at.allow [at] (5) - determine who can submit jobs via at or batch
|
||||
at.deny [at] (5) - determine who can submit jobs via at or batch
|
||||
jwhois (1) - client for the whois service
|
||||
jwhois (rpm) - Internet whois/nicname client.
|
||||
Net::LDAP::Extension::whoami (3pm) - LDAP Who am I? Operation
|
||||
w (1) - Show who is logged on and what they are doing
|
||||
who (1p) - display who is on the system
|
||||
who (1) - show who is logged on
|
||||
whoami (1) - print effective userid
|
||||
|
||||
[root@localhost ~]# apropos who
|
||||
at.allow [at] (5) - determine who can submit jobs via at or batch
|
||||
at.deny [at] (5) - determine who can submit jobs via at or batch
|
||||
jwhois (1) - client for the whois service
|
||||
jwhois (rpm) - Internet whois/nicname client.
|
||||
Net::LDAP::Extension::WhoAmI (3pm) - LDAP Who am I? Operation
|
||||
w (1) - Show who is logged on and what they are doing
|
||||
who (1p) - display who is on the system
|
||||
who (1) - show who is logged on
|
||||
whoami (1) - print effective userid
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># man -k who</span>
|
||||
at.allow <span class="token punctuation">[</span>at<span class="token punctuation">]</span> <span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span> - determine <span class="token function">who</span> can submit <span class="token function">jobs</span> via at or batch
|
||||
at.deny <span class="token punctuation">[</span>at<span class="token punctuation">]</span> <span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span> - determine <span class="token function">who</span> can submit <span class="token function">jobs</span> via at or batch
|
||||
jwhois <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> - client <span class="token keyword">for</span> the whois <span class="token function">service</span>
|
||||
|
|
@ -102,7 +138,8 @@ w <span class="token punctuation">(</span><span class="token
|
|||
<span class="token function">whoami</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> - print effective userid
|
||||
</code></pre>
|
||||
<p>查找手册页名字和描述中包含emacs和vi的手册页:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apropos</span> -a emacs <span class="token function">vi</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apropos -a emacs vi
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apropos</span> -a emacs <span class="token function">vi</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -129,7 +166,7 @@ w <span class="token punctuation">(</span><span class="token
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198078"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198078"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219442"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219442"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apt-get,Debian Linux发行版中的APT软件包管理工具">
|
||||
<title>apt-get 命令,Linux apt-get 命令详解:Debian Linux发行版中的APT软件包管理工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198107">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219468">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,22 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>apt-get命令</strong> 是Debian Linux发行版中的APT软件包管理工具。所有基于Debian的发行都使用这个包管理系统。deb包可以把一个应用的文件包在一起,大体就如同Windows上的安装文件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span> PACKAGE
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get [OPTION] PACKAGE
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span> PACKAGE
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> <span class="token comment"># 安装新包</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get install # 安装新包
|
||||
apt-get remove # 卸载已安装的包(保留配置文件)
|
||||
apt-get purge # 卸载已安装的包(删除配置文件)
|
||||
apt-get update # 更新软件包列表
|
||||
apt-get upgrade # 更新所有已安装的包
|
||||
apt-get autoremove # 卸载已不需要的包依赖
|
||||
apt-get dist-upgrade # 自动处理依赖包升级
|
||||
apt-get autoclean # 将已经删除了的软件包的.deb安装文件从硬盘中删除掉
|
||||
apt-get clean # 删除软件包的安装包
|
||||
|
||||
-c:指定配置文件。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> <span class="token comment"># 安装新包</span>
|
||||
<span class="token function">apt-get</span> remove <span class="token comment"># 卸载已安装的包(保留配置文件)</span>
|
||||
<span class="token function">apt-get</span> purge <span class="token comment"># 卸载已安装的包(删除配置文件)</span>
|
||||
<span class="token function">apt-get</span> update <span class="token comment"># 更新软件包列表</span>
|
||||
|
|
@ -79,35 +91,45 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>使用apt-get命令的第一步就是引入必需的软件库,Debian的软件库也就是所有Debian软件包的集合,它们存在互联网上的一些公共站点上。把它们的地址加入,apt-get就能搜索到我们想要的软件。/etc/apt/sources.list是存放这些地址列表的配置文件,其格式如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">deb web或<span class="token punctuation">[</span>ftp地址<span class="token punctuation">]</span> <span class="token punctuation">[</span>发行版名字<span class="token punctuation">]</span> main/contrib/non-<span class="token punctuation">[</span>free<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="deb web或[ftp地址] [发行版名字] main/contrib/non-[free]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">deb web或<span class="token punctuation">[</span>ftp地址<span class="token punctuation">]</span> <span class="token punctuation">[</span>发行版名字<span class="token punctuation">]</span> main/contrib/non-<span class="token punctuation">[</span>free<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<p>我们常用的Ubuntu就是一个基于Debian的发行,我们使用apt-get命令获取这个列表,以下是我整理的常用命令:</p>
|
||||
<p>在修改<code>/etc/apt/sources.list</code>或者<code>/etc/apt/preferences</code>之后运行该命令。此外您需要定期运行这一命令以确保您的软件包列表是最新的:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> update
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get update
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> update
|
||||
</code></pre>
|
||||
<p>安装一个新软件包:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> packagename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get install packagename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> packagename
|
||||
</code></pre>
|
||||
<p>卸载一个已安装的软件包(保留配置文件):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> remove packagename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get remove packagename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> remove packagename
|
||||
</code></pre>
|
||||
<p>卸载一个已安装的软件包(删除配置文件):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> –purge remove packagename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get –purge remove packagename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> –purge remove packagename
|
||||
</code></pre>
|
||||
<p>会把已装或已卸的软件都备份在硬盘上,所以如果需要空间的话,可以让这个命令来删除你已经删掉的软件:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> autoclean <span class="token function">apt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get autoclean apt
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> autoclean <span class="token function">apt</span>
|
||||
</code></pre>
|
||||
<p>这个命令会把安装的软件的备份也删除,不过这样不会影响软件的使用的:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> clean
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get clean
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> clean
|
||||
</code></pre>
|
||||
<p>更新所有已安装的软件包:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> upgrade
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get upgrade
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> upgrade
|
||||
</code></pre>
|
||||
<p>将系统升级到新版本:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> dist-upgrade
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get dist-upgrade
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> dist-upgrade
|
||||
</code></pre>
|
||||
<p>定期运行这个命令来清除那些已经卸载的软件包的.deb文件。通过这种方式,您可以释放大量的磁盘空间。如果您的需求十分迫切,可以使用<code>apt-get clean</code>以释放更多空间。这个命令会将已安装软件包裹的.deb文件一并删除。大多数情况下您不会再用到这些.debs文件,因此如果您为磁盘空间不足 而感到焦头烂额,这个办法也许值得一试:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> autoclean
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get autoclean
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> autoclean
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -134,7 +156,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198108"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198108"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219468"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219468"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apt-key,管理Debian Linux系统中的软件包密钥">
|
||||
<title>apt-key 命令,Linux apt-key 命令详解:管理Debian Linux系统中的软件包密钥 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198116">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219475">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,12 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>apt-key命令</strong> 用于管理Debian Linux系统中的软件包密钥。每个发布的deb包,都是通过密钥认证的,apt-key用来管理密钥。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">apt-key<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-key(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apt-key<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>操作指令:APT密钥操作指令。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">apt-key list <span class="token comment"># 列出已保存在系统中key。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-key list # 列出已保存在系统中key。
|
||||
apt-key add keyname # 把下载的key添加到本地trusted数据库中。
|
||||
apt-key del keyname # 从本地trusted数据库删除key。
|
||||
apt-key update # 更新本地trusted数据库,删除过期没用的key。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apt-key list <span class="token comment"># 列出已保存在系统中key。</span>
|
||||
apt-key <span class="token function">add</span> keyname <span class="token comment"># 把下载的key添加到本地trusted数据库中。</span>
|
||||
apt-key del keyname <span class="token comment"># 从本地trusted数据库删除key。</span>
|
||||
apt-key update <span class="token comment"># 更新本地trusted数据库,删除过期没用的key。</span>
|
||||
|
|
@ -92,7 +97,7 @@ apt-key update <span class="token comment"># 更新本地trusted数据库
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198117"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198117"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219476"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219476"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,apt-sortpkgs,Debian Linux下对软件包索引文件进行排序的工具">
|
||||
<title>apt-sortpkgs 命令,Linux apt-sortpkgs 命令详解:Debian Linux下对软件包索引文件进行排序的工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198126">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219484">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,13 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>apt-sortpkgs命令</strong> 是Debian Linux下对软件包索引文件进行排序的简单工具。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">apt-sortpkgs<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-sortpkgs(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">apt-sortpkgs<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-s:使用源索引字段排序;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-s:使用源索引字段排序;
|
||||
-h:显示帮助信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-s:使用源索引字段排序;
|
||||
-h:显示帮助信息。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
|
|
@ -90,7 +93,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198127"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198127"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219484"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219484"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,aptitude,Debian Linux系统中软件包管理工具">
|
||||
<title>aptitude 命令,Linux aptitude 命令详解:Debian Linux系统中软件包管理工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198139">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219496">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>aptitude命令</strong> 与apt-get命令一样,都是Debian Linux及其衍生系统中功能极其强大的包管理工具。与apt-get不同的是,aptitude在处理依赖问题上更佳一些。举例来说,aptitude在删除一个包时,会同时删除本身所依赖的包。这样,系统中不会残留无用的包,整个系统更为干净。它通过文本操作菜单和命令两种方式管理软件包。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">aptitude<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="aptitude(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">aptitude<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-h:显示帮助信息;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-h:显示帮助信息;
|
||||
-d:仅下载软件包,不执行安装操作;
|
||||
-P:每一步操作都要求确认;
|
||||
-y:所有问题都回答“yes”;
|
||||
-v:显示附加信息;
|
||||
-u:启动时下载新的软件包列表。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-h:显示帮助信息;
|
||||
-d:仅下载软件包,不执行安装操作;
|
||||
-P:每一步操作都要求确认;
|
||||
-y:所有问题都回答“yes”;
|
||||
|
|
@ -71,7 +78,17 @@
|
|||
<p>操作命令:用户管理软件包的操作命令。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>以下是我总结的一些常用aptitude命令,仅供参考:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">aptitude</span> update <span class="token comment"># 更新可用的包列表</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="aptitude update # 更新可用的包列表
|
||||
aptitude upgrade # 升级可用的包
|
||||
aptitude dist-upgrade # 将系统升级到新的发行版
|
||||
aptitude install pkgname # 安装包
|
||||
aptitude remove pkgname # 删除包
|
||||
aptitude purge pkgname # 删除包及其配置文件
|
||||
aptitude search string # 搜索包
|
||||
aptitude show pkgname # 显示包的详细信息
|
||||
aptitude clean # 删除下载的包文件
|
||||
aptitude autoclean # 仅删除过期的包文件
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">aptitude</span> update <span class="token comment"># 更新可用的包列表</span>
|
||||
<span class="token function">aptitude</span> upgrade <span class="token comment"># 升级可用的包</span>
|
||||
<span class="token function">aptitude</span> dist-upgrade <span class="token comment"># 将系统升级到新的发行版</span>
|
||||
<span class="token function">aptitude</span> <span class="token function">install</span> pkgname <span class="token comment"># 安装包</span>
|
||||
|
|
@ -108,7 +125,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198140"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198140"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219497"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219497"></script>
|
||||
</body>
|
||||
</html>
|
||||
130
c/ar.html
130
c/ar.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,ar,建立或修改备存文件,或是从备存文件中抽取文件">
|
||||
<title>ar 命令,Linux ar 命令详解:建立或修改备存文件,或是从备存文件中抽取文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198189">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219540">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,12 +57,99 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>ar命令</strong> 是一个建立或修改备存文件,或是从备存文件中抽取文件的工具,ar可让您集合许多文件,成为单一的备存文件。在备存文件中,所有成员文件皆保有原来的属性与权限</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">ar <span class="token punctuation">[</span>-<span class="token punctuation">]</span><span class="token punctuation">{</span>dmpqrtx<span class="token punctuation">}</span><span class="token punctuation">[</span>abcfilNoPsSuvV<span class="token punctuation">]</span> <span class="token punctuation">[</span>membername<span class="token punctuation">]</span> <span class="token punctuation">[</span>count<span class="token punctuation">]</span> archive files<span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ar [-]{dmpqrtx}[abcfilNoPsSuvV] [membername] [count] archive files...
|
||||
Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
|
||||
ar -M [<mri-脚本]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ar <span class="token punctuation">[</span>-<span class="token punctuation">]</span><span class="token punctuation">{</span>dmpqrtx<span class="token punctuation">}</span><span class="token punctuation">[</span>abcfilNoPsSuvV<span class="token punctuation">]</span> <span class="token punctuation">[</span>membername<span class="token punctuation">]</span> <span class="token punctuation">[</span>count<span class="token punctuation">]</span> archive files<span class="token punctuation">..</span>.
|
||||
Usage: ar <span class="token punctuation">[</span>emulation options<span class="token punctuation">]</span> <span class="token punctuation">[</span>-<span class="token punctuation">]</span><span class="token punctuation">{</span>dmpqrstx<span class="token punctuation">}</span><span class="token punctuation">[</span>abcDfilMNoPsSTuvV<span class="token punctuation">]</span> <span class="token punctuation">[</span>--plugin <span class="token operator"><</span>name<span class="token operator">></span><span class="token punctuation">]</span> <span class="token punctuation">[</span>member-name<span class="token punctuation">]</span> <span class="token punctuation">[</span>count<span class="token punctuation">]</span> archive-file file<span class="token punctuation">..</span>.
|
||||
ar -M <span class="token punctuation">[</span><span class="token operator"><</span>mri-脚本<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">ar 允许你 在第一个 命令行 参数中 以任意 顺序 混合 指定 操作码p 和修饰符mod <span class="token builtin class-name">.</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ar 允许你 在第一个 命令行 参数中 以任意 顺序 混合 指定 操作码p 和修饰符mod .
|
||||
|
||||
只要你 愿意, 也可以 用破折号 作为 命令行 第一个 参数的 开始.
|
||||
|
||||
p 关键字 指明 要执行的 操作, 只能 指明为 如下 之一:
|
||||
|
||||
d 从档案中删除 模块. 通过files 指明 要删除的 模块的 名称; 如果 没有 指出 要删除的 文件 名称, 档案不会 改变 任何
|
||||
内容.
|
||||
|
||||
如果 给出了'v' 修饰符,ar 会例出 它删除的 每一个 模块.
|
||||
|
||||
m 用此 操作 在档案中移动 成员.
|
||||
如果 某个 符号名 在档案的 多个 成员中 有定义, 那么 程序 怎样 连接 档案 文件 得到的 结果 可能是 不同的.
|
||||
如果 没有为m 指定 修饰符, 由files 指出的 成员 将移动到 档案的末尾 ; 可以 通过 `a', `b' 或 `i' 等修饰符, 指定 成员
|
||||
移动的 具体 位置.
|
||||
|
||||
p 在标准 输出上 打印 档案中 指定的 成员. 如果 给出了`v' 修饰符, 在 打印 成员 内容 之前, 先打印 成员的 名字.
|
||||
如果没有 指明files 参数, 档案中 所有的 成员 都会被 打印 出来.
|
||||
|
||||
q 快速 追加; 增加 files 到 archive 的末尾, 不进行 替换 检查.
|
||||
修饰符 `a' `b' 和 `i'不 影响此 操作, 新成员 始终 追加到 档案的 末尾处.
|
||||
修饰符 `v' 可以使 ar 列出 它追加的 所有文件.
|
||||
由于 本功能 是用于 快速操作, 即使 档案中 有 符号表 索引 也不 进行 更新; 可以 使用 `ar s' 或 ranlib 明确 要求 更新
|
||||
这些索引.
|
||||
|
||||
在为快速 追加 重建 索引时,由于 有 太多 不同的 系统, 所以 GNU ar 采用 `q' 作为 `r'的一个 同义字.
|
||||
|
||||
r 把文件 files 插入 archive ( 替换 ). 本操作与 `q' 是不同的, 如果 档案中 已有的 某个 成员与 插入 文件的 名称 相同,
|
||||
此成员 将被删除.
|
||||
如果 不存在 名称为 files 的文件, ar 显示 一个 错误 消息, 并且 保留 档案中 已有的 同名 成员.
|
||||
缺省情况下, 新成员 增加到 挡案的 末尾; 可以 通过 使用 `a' `b' 或 `i' 等修饰符 指定 相对于 已有 成员的 位置.
|
||||
通过 使用 `v' 修饰符 会为每个 插入的 文件 产生 一行 输出, 根据 输出中的 字符 `a' 或 `r' 可以 表明 该文件 是追加的
|
||||
(没有 删除 以前的成员) 还是 替换的.
|
||||
|
||||
t 显示 一个 archive 档案 所包含 内容的 列表 , 或 档案中的 由 files 指出的 文件 列表. 通常 只显示 成员的 名称, 如果
|
||||
使用 `v' 修饰符, 可以 得到 成员的 权限, 时间属性, 属主, 组和 大小.
|
||||
|
||||
如果 没有 指出 files, 档案中的 所有 文件 都会 列出.
|
||||
|
||||
如果 档案中 (称为 `b.a') 有多个 同名 成员 (称为 `fie'), `ar t b.a fie' 仅仅 列出 第一个; 要看到 它们的 全部, 必须
|
||||
要求 完整的 列表 —在本例中是 `ar t b.a'.
|
||||
|
||||
x 从档案中 抽取 成员 (名称为 files) . 如果 使用 `v' 修饰符, ar 会列出 它抽取的 每一个 文件的 名字.
|
||||
如果没有给出 files, 抽取 档案中 所有的 文件.
|
||||
|
||||
可以在 操作符 p 后紧随 一定数量的 修饰符 mod 以指明 操作的 各种 行为.
|
||||
|
||||
a 增加 文件到 档案中 已有 成员 之后 , 如果 使用了 修饰符 a, 必须在 档案 名称 archive 之前 以 membername 参数的 形式
|
||||
给出 档案中 已有 成员的 名字.
|
||||
|
||||
b 增加 文件到 档案中 已有 成员 之前 , 如果 使用了 修饰符 b, 必须在 档案 名称 archive 之前 以 membername 参数的 形式
|
||||
给出 档案中 已有 成员的 名字. (和修饰符 `i' 相同).
|
||||
|
||||
c 建立 档案. 指定的 档案 archive 始终 会被建立, 如果 你要求 执行的是 更新, 通过 此修饰符 建立 档案时 会给出 一个
|
||||
警告.
|
||||
|
||||
f 截短 档案成员的 名字. ar 通常 允许 任意 长度的 文件名, 但这会 导致 与某些 系统上的 ar 出现 兼容性 问题, 使用 f
|
||||
修饰符 可以 在往档案中 追加 文件时 把名字 截短.
|
||||
|
||||
i 插入 文件到 档案中 已有 成员 之前 , 如果 使用了 修饰符 i, 必须在 档案 名称 archive 之前 以 membername 参数的 形式
|
||||
给出 档案中 已有 成员的 名字. (与修饰符 `b' 相同).
|
||||
|
||||
l 接受此修饰符, 但不起作用.
|
||||
|
||||
N 使用 count 参数. 本修饰符 用于 在档案中 有多个 同名 成员的 情况. 删除 或抽取 档案中 给定 名字的第 count 个实例.
|
||||
|
||||
o 抽取 成员时 保留 他们 原始的 时间属性. 如果 没有 此修饰符, 文件以抽取 的时间 作为 它的时间 属性.
|
||||
|
||||
P 匹配 档案中的 名字时 使用 完整的 路径名. ar 不能 建立 使用 完整 路径名的 档案 (这不符合 POSIX 标准), 但其它的
|
||||
档案 工具 能够建立, 本选项 会使 ar 在抽取 由其它 工具 建立的 档案 文件时, 使用完整的 路径名 去匹配 档案中 成员的
|
||||
名字.
|
||||
|
||||
s 即使 没有对 档案 进行 改变, 用本 修饰符 也可以 往档案中 写一个 目标 文件的 索引 或更新 已经 存在的 索引. 可以与
|
||||
其它 操作 一起 使用 本修饰符, 也可以 单独使用. 对一个 档案 执行 `ar s' 与执行 `ranlib' 等价.
|
||||
|
||||
S 不生成 档案的 符号表. 这可以 加速 建立 大的档案 文件的 过程,但这样 建立的 档案 不能被 连接器 使用, 为建立 符号表,
|
||||
在最后 执行 `ar' 时应该 不用 `S' 修饰符, 或者 对档案 执行 一次 `ranlib' .
|
||||
|
||||
u 通常ar r... 把所有 列出的 文件 插入到 档案中, 如果 希望 仅仅 插入比 档案中 已有 成员 更新的 文件时, 就应该 使用
|
||||
此修饰符. `u' 修饰符 仅允许 与 `r' (替换) 操作 一起 使用. 某些 情况下, 由于 用 `q' 操作 比较 文件的 时间属性
|
||||
会失去 速度上的 优势, 所以 不允许 执行 `qu' 组合操作.
|
||||
|
||||
v 使用本修饰符可以进行 冗余的 操作。附加了此修饰符时,很多操作会显示 更多的消息,如处理的文件名等。
|
||||
V 显示 ar 的版本号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ar 允许你 在第一个 命令行 参数中 以任意 顺序 混合 指定 操作码p 和修饰符mod <span class="token builtin class-name">.</span>
|
||||
|
||||
只要你 愿意, 也可以 用破折号 作为 命令行 第一个 参数的 开始.
|
||||
|
||||
|
|
@ -148,12 +235,21 @@ u 通常ar r<span class="token punctuation">..</span>. 把所有 列出的
|
|||
V 显示 ar 的版本号。
|
||||
</code></pre>
|
||||
<p>选项参数</p>
|
||||
<pre class="language-shell"><code class="language-shell">--plugin <span class="token operator"><</span>p<span class="token operator">></span> - load the specified plugin
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--plugin <p> - load the specified plugin
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--plugin <span class="token operator"><</span>p<span class="token operator">></span> - load the specified plugin
|
||||
</code></pre>
|
||||
<p>ar:支持的目标: elf64-x86-64 elf32-i386 elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>打包文件</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ls # 显示当前目录文件 </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# ls # 显示当前目录文件
|
||||
a.c b.c d.c install.log qte
|
||||
anaconda-ks.cfg c.c Desktop
|
||||
|
||||
[root@localhost ~]# ar rv one.bak a.c b.c # 打包 a.c b.c文件
|
||||
ar: 正在创建 one.bak
|
||||
a - a.c
|
||||
a - b.c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ls # 显示当前目录文件 </span>
|
||||
a.c b.c d.c install.log qte
|
||||
anaconda-ks.cfg c.c Desktop
|
||||
|
||||
|
|
@ -163,7 +259,13 @@ a - a.c
|
|||
a - b.c
|
||||
</code></pre>
|
||||
<p>打包多个文件</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar rv two.bak *.c // 打包以.c结尾的文件 </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# ar rv two.bak *.c // 打包以.c结尾的文件
|
||||
ar: 正在创建 two.bak
|
||||
a - a.c
|
||||
a - b.c
|
||||
a - c.c
|
||||
a - d.c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar rv two.bak *.c // 打包以.c结尾的文件 </span>
|
||||
ar: 正在创建 two.bak
|
||||
a - a.c
|
||||
a - b.c
|
||||
|
|
@ -171,14 +273,22 @@ a - c.c
|
|||
a - d.c
|
||||
</code></pre>
|
||||
<p>显示打包文件的内容</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar t two.bak </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# ar t two.bak
|
||||
a.c
|
||||
b.c
|
||||
c.c
|
||||
d.c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar t two.bak </span>
|
||||
a.c
|
||||
b.c
|
||||
c.c
|
||||
d.c
|
||||
</code></pre>
|
||||
<p>删除打包文件的成员文件</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar d two.bak a.c b.c c.c </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# ar d two.bak a.c b.c c.c
|
||||
[root@localhost ~]# ar t two.bak
|
||||
d.c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar d two.bak a.c b.c c.c </span>
|
||||
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># ar t two.bak </span>
|
||||
d.c
|
||||
</code></pre>
|
||||
|
|
@ -207,7 +317,7 @@ d.c
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198190"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198190"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219541"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219541"></script>
|
||||
</body>
|
||||
</html>
|
||||
17
c/arch.html
17
c/arch.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arch,显示当前主机的硬件架构类型">
|
||||
<title>arch 命令,Linux arch 命令详解:显示当前主机的硬件架构类型 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198205">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219553">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,18 +55,23 @@
|
|||
<h1 id="arch"><a class="anchor" aria-hidden="true" tabindex="-1" href="#arch"><span class="octicon octicon-link"></span></a>arch</h1>
|
||||
<p>显示当前主机的硬件架构类型</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell">arch <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arch [OPTION]...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arch <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
<li>打印机器架构信息;<code>arch</code> 命令输出结果有:i386、i486、i586、alpha、sparc、arm、m68k、mips、ppc、i686等。</li>
|
||||
</ul>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">--help 显示帮助信息并退出。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--help 显示帮助信息并退出。
|
||||
--version 显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--help 显示帮助信息并退出。
|
||||
--version 显示版本信息并退出。
|
||||
</code></pre>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arch</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# arch
|
||||
x86_64
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arch</span>
|
||||
x86_64
|
||||
</code></pre>
|
||||
<h3 id="注意"><a class="anchor" aria-hidden="true" tabindex="-1" href="#注意"><span class="octicon octicon-link"></span></a>注意</h3>
|
||||
|
|
@ -103,7 +108,7 @@ x86_64
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198206"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198206"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219553"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219553"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arj,用于创建和管理.arj压缩包">
|
||||
<title>arj 命令,Linux arj 命令详解:用于创建和管理.arj压缩包 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198212">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219559">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>arj命令</strong> 是 <code>.arj</code> 格式的压缩文件的管理器,用于创建和管理 <code>.arj</code> 压缩包。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arj<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arj(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arj<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198213"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198213"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219559"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219560"></script>
|
||||
</body>
|
||||
</html>
|
||||
35
c/arp.html
35
c/arp.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arp,arp 命令用于显示和修改 IP 到 MAC 转换表">
|
||||
<title>arp 命令,Linux arp 命令详解:arp 命令用于显示和修改 IP 到 MAC 转换表 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198230">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219577">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -63,10 +63,21 @@
|
|||
<p>如果在限定的时间(见下面的sysctl)内,一条现存映射没有肯定反馈时, 则认为相邻层的缓存记录失效。 为了再次向目标发送数据,ARP将首先试着询问本地arp进程 app_solicit 次,获取更新了的 MAC(介质访问控制)地址。 如果失败,并且旧的MAC地址是已知的,则发送 ucast_solicit 次的 unicast probe。如果仍然失败,则将向网络广播一个新的ARP请求,此时要 有待发送数据的队列</p>
|
||||
<p>如果 Linux 接到一个地址请求,而且该地址指向 Linux 转发的地址,并且接收接口打开了代理 arp 时,Linux 将自动添加一条非永久的代理 arp 记录;如果存在拒绝到目标的路由,则不添加代理 arp 记录。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arp(选项)(参数)
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arp(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arp(选项)(参数)
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a <span class="token comment"># 主机 :显示 arp 缓冲区的所有条目;</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a # 主机 :显示 arp 缓冲区的所有条目;
|
||||
-H # 地址类型 :指定 arp 指令使用的地址类型;
|
||||
-d # 主机 :从 arp 缓冲区中删除指定主机的 arp 条目;
|
||||
-D # 使用指定接口的硬件地址;
|
||||
-e # 以 Linux 的显示风格显示 arp 缓冲区中的条目;
|
||||
-i # 接口 :指定要操作 arp 缓冲区的网络接口;
|
||||
-s # 主机 MAC 地址 :设置指定的主机的 IP 地址与 MAC 地址的静态映射;
|
||||
-n # 以数字方式显示 arp 缓冲区中的条目;
|
||||
-v # 显示详细的 arp 缓冲区条目,包括缓冲区条目的统计信息;
|
||||
-f # 文件 :设置主机的 IP 地址与 MAC 地址的静态映射。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a <span class="token comment"># 主机 :显示 arp 缓冲区的所有条目;</span>
|
||||
-H <span class="token comment"># 地址类型 :指定 arp 指令使用的地址类型;</span>
|
||||
-d <span class="token comment"># 主机 :从 arp 缓冲区中删除指定主机的 arp 条目;</span>
|
||||
-D <span class="token comment"># 使用指定接口的硬件地址;</span>
|
||||
|
|
@ -81,18 +92,26 @@
|
|||
<p>主机:查询 arp 缓冲区中指定主机的 arp 条目。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>显示arp 缓冲区内容</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arp -v</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# arp -v
|
||||
Address HWtype HWaddress Flags Mask Iface
|
||||
192.168.0.134 ether 00:21:5E:C7:4D:88 C eth1
|
||||
115.238.144.129 ether 38:22:D6:2F:B2:F1 C eth0
|
||||
Entries: 2 Skipped: 0 Found: 2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arp -v</span>
|
||||
Address HWtype HWaddress Flags Mask Iface
|
||||
<span class="token number">192.168</span>.0.134 ether 00:21:5E:C7:4D:88 C eth1
|
||||
<span class="token number">115.238</span>.144.129 ether <span class="token number">38</span>:22:D6:2F:B2:F1 C eth0
|
||||
Entries: <span class="token number">2</span> Skipped: <span class="token number">0</span> Found: <span class="token number">2</span>
|
||||
</code></pre>
|
||||
<p>添加静态 arp 映射</p>
|
||||
<pre class="language-shell"><code class="language-shell">arp -s IP MAC-ADDRESS
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arp -s IP MAC-ADDRESS
|
||||
arp -s 192.168.1.1 00:b1:b2:b3:b4:b5
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arp -s IP MAC-ADDRESS
|
||||
arp -s <span class="token number">192.168</span>.1.1 00:b1:b2:b3:b4:b5
|
||||
</code></pre>
|
||||
<p>删除 arp 缓存条目</p>
|
||||
<pre class="language-shell"><code class="language-shell">arp -d <span class="token number">192.168</span>.1.1
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arp -d 192.168.1.1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arp -d <span class="token number">192.168</span>.1.1
|
||||
</code></pre><!-- Linux 命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||||
</div>
|
||||
|
||||
|
|
@ -119,7 +138,7 @@ arp -s <span class="token number">192.168</span>.1.1 00:b1:b2:b3:b4:b5
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198231"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198231"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219577"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219577"></script>
|
||||
</body>
|
||||
</html>
|
||||
23
c/arpd.html
23
c/arpd.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arpd,收集免费ARP信息">
|
||||
<title>arpd 命令,Linux arpd 命令详解:收集免费ARP信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198240">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219585">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>arpd命令</strong> 是用来收集免费arp信息的一个守护进程,它将收集到的信息保存在磁盘上或者在需要时,提供给内核用户用于避免多余广播。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arpd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arpd(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arpd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-l:将arp数据库输出到标准输出设备显示并退出;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-l:将arp数据库输出到标准输出设备显示并退出;
|
||||
-f:指定读取和加载arpd数据库的文本文件,文件的格式与“-l”输出信息类似;
|
||||
-b:指定arpd数据库文件,默认的位置为“/var/lib/arpd.db”;
|
||||
-a:指定目标被认为死掉前查询的次数;
|
||||
-k:禁止通过内核发送广播查询;
|
||||
-n:设定缓冲失效时间。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-l:将arp数据库输出到标准输出设备显示并退出;
|
||||
-f:指定读取和加载arpd数据库的文本文件,文件的格式与“-l”输出信息类似;
|
||||
-b:指定arpd数据库文件,默认的位置为“/var/lib/arpd.db”;
|
||||
-a:指定目标被认为死掉前查询的次数;
|
||||
|
|
@ -71,10 +78,12 @@
|
|||
<p>网络接口:指定网络接口。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>启动arpd进程:</p>
|
||||
<pre class="language-shell"><code class="language-shell">arpd -b /var/tmp/arpd.db
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arpd -b /var/tmp/arpd.db
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arpd -b /var/tmp/arpd.db
|
||||
</code></pre>
|
||||
<p>运行一段时间后,查看结果:</p>
|
||||
<pre class="language-shell"><code class="language-shell">arpd -l -b /var/tmp/arpd.db
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arpd -l -b /var/tmp/arpd.db
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arpd -l -b /var/tmp/arpd.db
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -101,7 +110,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198240"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198240"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219586"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219586"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arping,通过发送ARP协议报文测试网络">
|
||||
<title>arping 命令,Linux arping 命令详解:通过发送ARP协议报文测试网络 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198253">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219596">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,18 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>arping命令</strong> 是用于发送arp请求到一个相邻主机的工具,arping使用arp数据包,通过ping命令检查设备上的硬件地址。能够测试一个ip地址是否是在网络上已经被使用,并能够获取更多设备信息。功能类似于ping。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arping<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arping(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arping<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b:用于发送以太网广播帧(FFFFFFFFFFFF)。arping一开始使用广播地址,在收到响应后就使用unicast地址。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b:用于发送以太网广播帧(FFFFFFFFFFFF)。arping一开始使用广播地址,在收到响应后就使用unicast地址。
|
||||
-q:quiet output不显示任何信息;
|
||||
-f:表示在收到第一个响应报文后就退出;
|
||||
-w timeout:设定一个超时时间,单位是秒。如果到了指定时间,arping还没到完全收到响应则退出;
|
||||
-c count:表示发送指定数量的ARP请求数据包后就停止。如果指定了deadline选项,则arping会等待相同数量的arp响应包,直到超时为止;
|
||||
-s source:设定arping发送的arp数据包中的SPA字段的值。如果为空,则按下面处理,如果是DAD模式(冲突地址探测),则设置为0.0.0.0,如果是Unsolicited ARP模式(Gratutious ARP)则设置为目标地址,否则从路由表得出;
|
||||
-I interface:设置ping使用的网络接口。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b:用于发送以太网广播帧(FFFFFFFFFFFF)。arping一开始使用广播地址,在收到响应后就使用unicast地址。
|
||||
-q:quiet output不显示任何信息;
|
||||
-f:表示在收到第一个响应报文后就退出;
|
||||
-w timeout:设定一个超时时间,单位是秒。如果到了指定时间,arping还没到完全收到响应则退出;
|
||||
|
|
@ -71,7 +79,19 @@
|
|||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>目的主机:指定发送ARP报文的目的主机。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arping www.baidu.com </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# arping www.baidu.com
|
||||
ARPING 220.181.111.147 from 173.231.43.132 eth0
|
||||
Unicast reply from 220.181.111.147 00:D0:03:[bc:48:00] 1.666ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.677ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.691ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.728ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.626ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.292ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 1.429ms
|
||||
Unicast reply from 220.181.111.147 [00:D0:03:BC:48:00] 2.042ms
|
||||
Sent 8 probes (1 broadcast(s))
|
||||
Received 8 response(s)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># arping www.baidu.com </span>
|
||||
ARPING <span class="token number">220.181</span>.111.147 from <span class="token number">173.231</span>.43.132 eth0
|
||||
Unicast reply from <span class="token number">220.181</span>.111.147 00:D0:03:<span class="token punctuation">[</span>bc:48:00<span class="token punctuation">]</span> <span class="token number">1</span>.666ms
|
||||
Unicast reply from <span class="token number">220.181</span>.111.147 <span class="token punctuation">[</span>00:D0:03:BC:48:00<span class="token punctuation">]</span> <span class="token number">1</span>.677ms
|
||||
|
|
@ -109,7 +129,7 @@ Received <span class="token number">8</span> response<span class="token punctuat
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198253"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198253"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219596"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219596"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arptables,管理ARP包过滤规则表">
|
||||
<title>arptables 命令,Linux arptables 命令详解:管理ARP包过滤规则表 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198261">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219602">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,24 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>arptables命令</strong> 用来设置、维护和检查Linux内核中的arp包过滤规则表。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arptables<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arptables(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arptables<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-A:向规则链中追加规则;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-A:向规则链中追加规则;
|
||||
-D:从指定的链中删除规则;
|
||||
-l:向规则链中插入一条新的规则;
|
||||
-R:替换指定规则;
|
||||
-P:设置规则链的默认策略;
|
||||
-F:刷新指定规则链,将其中的所有规则链删除,但是不改变规则链的默认策略;
|
||||
-Z:将规则链计数器清零;
|
||||
-L:显示规则链中的规则列表;
|
||||
-X:删除指定的空用户自定义规则链;
|
||||
-h:显示指令帮助信息;
|
||||
-j:指定满足规则的添加时的目标;
|
||||
-s:指定要匹配ARP包的源ip地址;
|
||||
-d:指定要匹配ARP包的目的IP地址。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-A:向规则链中追加规则;
|
||||
-D:从指定的链中删除规则;
|
||||
-l:向规则链中插入一条新的规则;
|
||||
-R:替换指定规则;
|
||||
|
|
@ -99,7 +113,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198262"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198262"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219603"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219603"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,arpwatch,监听网络上ARP的记录">
|
||||
<title>arpwatch 命令,Linux arpwatch 命令详解:监听网络上ARP的记录 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198269">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219610">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>arpwatch命令</strong> 用来监听网络上arp的记录。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">arpwatch<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="arpwatch(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">arpwatch<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-d:启动排错模式;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-d:启动排错模式;
|
||||
-f<记录文件>:设置存储ARP记录的文件,预设为/var/arpwatch/arp.dat;
|
||||
-i<接口>:指定监听ARP的接口,预设的接口为eth0;
|
||||
-r<记录文件>:从指定的文件中读取ARP记录,而不是从网络上监听。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-d:启动排错模式;
|
||||
-f<span class="token operator"><</span>记录文件<span class="token operator">></span>:设置存储ARP记录的文件,预设为/var/arpwatch/arp.dat;
|
||||
-i<span class="token operator"><</span>接口<span class="token operator">></span>:指定监听ARP的接口,预设的接口为eth0;
|
||||
-r<span class="token operator"><</span>记录文件<span class="token operator">></span>:从指定的文件中读取ARP记录,而不是从网络上监听。
|
||||
|
|
@ -90,7 +95,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198270"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198270"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219611"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219611"></script>
|
||||
</body>
|
||||
</html>
|
||||
26
c/as.html
26
c/as.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,as,汇编语言编译器">
|
||||
<title>as 命令,Linux as 命令详解:汇编语言编译器 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198277">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219617">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,26 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>as命令</strong> GNU组织推出的一款汇编语言编译器,它支持多种不同类型的处理器。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">as<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="as(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">as<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-ac:忽略失败条件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-ac:忽略失败条件;
|
||||
-ad:忽略调试指令;
|
||||
-ah:包括高级源;
|
||||
-al:包括装配;
|
||||
-am:包括宏扩展;
|
||||
-an:忽略形式处理;
|
||||
-as:包括符号;
|
||||
=file:设置列出文件的名字;
|
||||
--alternate:以交互宏模式开始;
|
||||
-f:跳过空白和注释预处理;
|
||||
-g:产生调试信息;
|
||||
-J:对于有符号溢出不显示警告信息;
|
||||
-L:在符号表中保留本地符号;
|
||||
-o:指定要生成的目标文件;
|
||||
--statistics:打印汇编所用的最大空间和总时间。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-ac:忽略失败条件;
|
||||
-ad:忽略调试指令;
|
||||
-ah:包括高级源;
|
||||
-al:包括装配;
|
||||
|
|
@ -103,7 +119,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198278"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198278"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219617"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219617"></script>
|
||||
</body>
|
||||
</html>
|
||||
50
c/at.html
50
c/at.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,at,在指定时间执行一个任务">
|
||||
<title>at 命令,Linux at 命令详解:在指定时间执行一个任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198298">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219636">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,10 +58,16 @@
|
|||
<p><strong>at命令</strong> 用于在指定时间执行命令。at允许使用一套相当复杂的指定时间的方法。它能够接受在当天的hh:mm(小时:分钟)式的时间指定。假如该时间已过去,那么就放在第二天执行。当然也能够使用midnight(深夜),noon(中午),teatime(饮茶时间,一般是下午4点)等比较模糊的 词语来指定时间。用户还能够采用12小时计时制,即在时间后面加上AM(上午)或PM(下午)来说明是上午还是下午。 也能够指定命令执行的具体日期,指定格式为month day(月 日)或mm/dd/yy(月/日/年)或dd.mm.yy(日.月.年)。指定的日期必须跟在指定时间的后面。</p>
|
||||
<p>上面介绍的都是绝对计时法,其实还能够使用相对计时法,这对于安排不久就要执行的命令是很有好处的。指定格式为:<code>now + count time-units</code>,now就是当前时间,time-units是时间单位,这里能够是minutes(分钟)、hours(小时)、days(天)、weeks(星期)。count是时间的数量,究竟是几天,还是几小时,等等。 更有一种计时方法就是直接使用today(今天)、tomorrow(明天)来指定完成命令的时间。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">at <span class="token punctuation">[</span>-V<span class="token punctuation">]</span> <span class="token punctuation">[</span>-q 队列<span class="token punctuation">]</span> <span class="token punctuation">[</span>-f 文件<span class="token punctuation">]</span> <span class="token punctuation">[</span>-mldbv<span class="token punctuation">]</span> 时间 at -c 作业 <span class="token punctuation">[</span>作业<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="at [-V] [-q 队列] [-f 文件] [-mldbv] 时间 at -c 作业 [作业...]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">at <span class="token punctuation">[</span>-V<span class="token punctuation">]</span> <span class="token punctuation">[</span>-q 队列<span class="token punctuation">]</span> <span class="token punctuation">[</span>-f 文件<span class="token punctuation">]</span> <span class="token punctuation">[</span>-mldbv<span class="token punctuation">]</span> 时间 at -c 作业 <span class="token punctuation">[</span>作业<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-f:指定包含具体指令的任务文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f:指定包含具体指令的任务文件;
|
||||
-q:指定新任务的队列名称;
|
||||
-l:显示待执行任务的列表;
|
||||
-d:删除指定的待执行任务;
|
||||
-m:任务执行完成后向用户发送E-mail。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f:指定包含具体指令的任务文件;
|
||||
-q:指定新任务的队列名称;
|
||||
-l:显示待执行任务的列表;
|
||||
-d:删除指定的待执行任务;
|
||||
|
|
@ -71,24 +77,42 @@
|
|||
<p>日期时间:指定任务执行的日期时间。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>三天后的下午 5 点锺执行<code>/bin/ls</code>:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at 5pm+3 days</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# at 5pm+3 days
|
||||
at> /bin/ls
|
||||
at> <EOT>
|
||||
job 7 at 2013-01-08 17:00
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at 5pm+3 days</span>
|
||||
at<span class="token operator">></span> /bin/ls
|
||||
at<span class="token operator">></span> <span class="token operator"><</span>EOT<span class="token operator">></span>
|
||||
job <span class="token number">7</span> at <span class="token number">2013</span>-01-08 <span class="token number">17</span>:00
|
||||
</code></pre>
|
||||
<p>明天17点钟,输出时间到指定文件内:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at 17:20 tomorrow</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# at 17:20 tomorrow
|
||||
at> date >/root/2013.log
|
||||
at> <EOT>
|
||||
job 8 at 2013-01-06 17:20
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at 17:20 tomorrow</span>
|
||||
at<span class="token operator">></span> <span class="token function">date</span> <span class="token operator">></span>/root/2013.log
|
||||
at<span class="token operator">></span> <span class="token operator"><</span>EOT<span class="token operator">></span>
|
||||
job <span class="token number">8</span> at <span class="token number">2013</span>-01-06 <span class="token number">17</span>:20
|
||||
</code></pre>
|
||||
<p>计划任务设定后,在没有执行之前我们可以用atq命令来查看系统没有执行工作任务:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># atq</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# atq
|
||||
8 2013-01-06 17:20 a root
|
||||
7 2013-01-08 17:00 a root
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># atq</span>
|
||||
<span class="token number">8</span> <span class="token number">2013</span>-01-06 <span class="token number">17</span>:20 a root
|
||||
<span class="token number">7</span> <span class="token number">2013</span>-01-08 <span class="token number">17</span>:00 a root
|
||||
</code></pre>
|
||||
<p>删除已经设置的任务:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># atq</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# atq
|
||||
8 2013-01-06 17:20 a root
|
||||
7 2013-01-08 17:00 a root
|
||||
|
||||
[root@localhost ~]# atrm 7
|
||||
[root@localhost ~]# atq
|
||||
8 2013-01-06 17:20 a root
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># atq</span>
|
||||
<span class="token number">8</span> <span class="token number">2013</span>-01-06 <span class="token number">17</span>:20 a root
|
||||
<span class="token number">7</span> <span class="token number">2013</span>-01-08 <span class="token number">17</span>:00 a root
|
||||
|
||||
|
|
@ -97,7 +121,13 @@ job <span class="token number">8</span> at <span class="token number">2013</span
|
|||
<span class="token number">8</span> <span class="token number">2013</span>-01-06 <span class="token number">17</span>:20 a root
|
||||
</code></pre>
|
||||
<p>显示已经设置的任务内容:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at -c 8</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# at -c 8
|
||||
#!/bin/sh
|
||||
# atrun uid=0 gid=0
|
||||
# mail root 0
|
||||
umask 22此处省略n个字符
|
||||
date >/root/2013.log
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># at -c 8</span>
|
||||
<span class="token comment">#!/bin/sh</span>
|
||||
<span class="token comment"># atrun uid=0 gid=0</span>
|
||||
<span class="token comment"># mail root 0</span>
|
||||
|
|
@ -129,7 +159,7 @@ job <span class="token number">8</span> at <span class="token number">2013</span
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198299"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198299"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219637"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219637"></script>
|
||||
</body>
|
||||
</html>
|
||||
15
c/atop.html
15
c/atop.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,atop,监控Linux系统资源与进程的工具">
|
||||
<title>atop 命令,Linux atop 命令详解:监控Linux系统资源与进程的工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198327">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219661">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p>[非内部程序,需要安装]它以一定的频率记录系统的运行状态,所采集的数据包含系统资源(CPU、内存、磁盘和网络)使用情况和进程运行情况,并能以日志文件的方式保存在磁盘中,服务器出现问题后,我们可获取相应的atop日志文件进行分析。atop是一款开源软件,我们可以从这里获得其源码和rpm安装包。</p>
|
||||
<h2 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h2>
|
||||
<pre class="language-shell"><code class="language-shell">atop<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="atop(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">atop<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h2 id="说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#说明"><span class="octicon octicon-link"></span></a>说明</h2>
|
||||
<p><strong>ATOP列</strong>:该列显示了主机名、信息采样日期和时间点</p>
|
||||
|
|
@ -118,10 +119,12 @@
|
|||
<li>设定日志失效期限,自动删除一段时间前的日志文件</li>
|
||||
</ul>
|
||||
<p>其实atop开发者已经提供了以上日志保存方式,相应的atop.daily脚本可以在源码目录下找到。在atop.daily脚本中,我们可以通过修改INTERVAL变量改变atop信息采样周期(默认为10分钟);通过修改以下命令中的数值改变日志保存天数(默认为28天):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">(</span>sleep <span class="token number">3</span><span class="token punctuation">;</span> <span class="token function">find</span> <span class="token variable">$LOGPATH</span> -name <span class="token string">'atop_*'</span> -mtime +28 -exec <span class="token function">rm</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span> <span class="token punctuation">)</span><span class="token operator">&</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="(sleep 3; find $LOGPATH -name 'atop_*' -mtime +28 -exec rm {} \; )&
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">(</span>sleep <span class="token number">3</span><span class="token punctuation">;</span> <span class="token function">find</span> <span class="token variable">$LOGPATH</span> -name <span class="token string">'atop_*'</span> -mtime +28 -exec <span class="token function">rm</span> <span class="token punctuation">{</span><span class="token punctuation">}</span> <span class="token punctuation">\</span><span class="token punctuation">;</span> <span class="token punctuation">)</span><span class="token operator">&</span>
|
||||
</code></pre>
|
||||
<p>最后,我们修改cron文件,每天凌晨执行atop.daily脚本:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0</span> <span class="token number">0</span> * * * root /etc/cron.daily/atop.daily
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0 0 * * * root /etc/cron.daily/atop.daily
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0</span> <span class="token number">0</span> * * * root /etc/cron.daily/atop.daily
|
||||
</code></pre>
|
||||
<h2 id="相关资料"><a class="anchor" aria-hidden="true" tabindex="-1" href="#相关资料"><span class="octicon octicon-link"></span></a>相关资料</h2>
|
||||
<ul>
|
||||
|
|
@ -152,7 +155,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198328"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198328"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219662"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219662"></script>
|
||||
</body>
|
||||
</html>
|
||||
22
c/atq.html
22
c/atq.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,atq,列出当前用户的at任务列表">
|
||||
<title>atq 命令,Linux atq 命令详解:列出当前用户的at任务列表 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198344">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219672">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,14 +57,24 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>atq命令</strong> 显示系统中待执行的任务列表,也就是列出当前用户的at任务列表。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">atq <span class="token punctuation">[</span>-V<span class="token punctuation">]</span> <span class="token punctuation">[</span>-q 队列<span class="token punctuation">]</span> <span class="token punctuation">[</span>-v<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="atq [-V] [-q 队列] [-v]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">atq <span class="token punctuation">[</span>-V<span class="token punctuation">]</span> <span class="token punctuation">[</span>-q 队列<span class="token punctuation">]</span> <span class="token punctuation">[</span>-v<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-V:显示版本号;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-V:显示版本号;
|
||||
-q:查询指定队列的任务。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-V:显示版本号;
|
||||
-q:查询指定队列的任务。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">at now + <span class="token number">10</span> minutes
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="at now + 10 minutes
|
||||
at> echo 1111
|
||||
at> <eot>
|
||||
job 3 at Fri Apr 26 12:56:00 2013
|
||||
|
||||
atq
|
||||
3 Fri Apr 26 12:56:00 2013 a root
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">at now + <span class="token number">10</span> minutes
|
||||
at<span class="token operator">></span> <span class="token builtin class-name">echo</span> <span class="token number">1111</span>
|
||||
at<span class="token operator">></span> <span class="token operator"><</span>eot<span class="token operator">></span>
|
||||
job <span class="token number">3</span> at Fri Apr <span class="token number">26</span> <span class="token number">12</span>:56:00 <span class="token number">2013</span>
|
||||
|
|
@ -97,7 +107,7 @@ atq
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198345"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198345"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219672"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219672"></script>
|
||||
</body>
|
||||
</html>
|
||||
19
c/atrm.html
19
c/atrm.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,atrm,删除待执行任务队列中的指定任务">
|
||||
<title>atrm 命令,Linux atrm 命令详解:删除待执行任务队列中的指定任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198353">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219680">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,16 +57,23 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>atrm命令</strong> 用于删除待执行任务队列中的指定任务。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">atrm<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="atrm(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">atrm<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-V:显示版本号。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-V:显示版本号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-V:显示版本号。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>任务号:指定待执行队列中要删除的任务。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>删除已经排队的任务</p>
|
||||
<pre class="language-shell"><code class="language-shell">atq <span class="token comment"># 显示当前已经设置的任务</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="atq # 显示当前已经设置的任务
|
||||
2 Mon May 17 08:00:00 2010 a root
|
||||
1 Sat May 15 17:00:00 2010 a root
|
||||
|
||||
atrm 2 # 删除任务2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">atq <span class="token comment"># 显示当前已经设置的任务</span>
|
||||
<span class="token number">2</span> Mon May <span class="token number">17</span> 08:00:00 <span class="token number">2010</span> a root
|
||||
<span class="token number">1</span> Sat May <span class="token number">15</span> <span class="token number">17</span>:00:00 <span class="token number">2010</span> a root
|
||||
|
||||
|
|
@ -97,7 +104,7 @@ atrm <span class="token number">2</span> <span class="token comment"># 删
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198354"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198354"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219681"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219681"></script>
|
||||
</body>
|
||||
</html>
|
||||
476
c/awk.html
476
c/awk.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,awk,文本和数据进行处理的编程语言">
|
||||
<title>awk 命令,Linux awk 命令详解:文本和数据进行处理的编程语言 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198668">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219985">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,7 +58,9 @@
|
|||
<p><strong>awk</strong> 是一种编程语言,用于在linux/unix下对文本和数据进行处理。数据可以来自标准输入(stdin)、一个或多个文件,或其它命令的输出。它支持用户自定义函数和动态正则表达式等先进功能,是linux/unix下的一个强大编程工具。它在命令行中使用,但更多是作为脚本来使用。awk有很多内建的功能,比如数组、函数等,这是它和C语言的相同之处,灵活性是awk最大的优势。</p>
|
||||
<h2 id="awk命令格式和选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk命令格式和选项"><span class="octicon octicon-link"></span></a>awk命令格式和选项</h2>
|
||||
<p><strong>语法形式</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token string">'script'</span> <span class="token assign-left variable">var</span><span class="token operator">=</span>value file<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk [options] 'script' var=value file(s)
|
||||
awk [options] -f scriptfile var=value file(s)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token string">'script'</span> <span class="token assign-left variable">var</span><span class="token operator">=</span>value file<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
|
||||
<span class="token function">awk</span> <span class="token punctuation">[</span>options<span class="token punctuation">]</span> -f scriptfile <span class="token assign-left variable">var</span><span class="token operator">=</span>value file<span class="token punctuation">(</span>s<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<p><strong>常用命令选项</strong></p>
|
||||
|
|
@ -87,14 +89,18 @@
|
|||
<li>控制流语句</li>
|
||||
</ul>
|
||||
<h2 id="awk脚本基本结构"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk脚本基本结构"><span class="octicon octicon-link"></span></a>awk脚本基本结构</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ print "start" } pattern{ commands } END{ print "end" }'</span> <span class="token function">file</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ print "start" } pattern{ commands } END{ print "end" }' file
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ print "start" } pattern{ commands } END{ print "end" }'</span> <span class="token function">file</span>
|
||||
</code></pre>
|
||||
<p>一个awk脚本通常由:BEGIN语句块、能够使用模式匹配的通用语句块、END语句块3部分组成,这三个部分是可选的。任意一个部分都可以不出现在脚本中,脚本通常是被 <strong>单引号</strong> 或 <strong>双引号</strong> 中,例如:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ i=0 } { i++ } END{ print i }'</span> filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ i=0 } { i++ } END{ print i }' filename
|
||||
awk "BEGIN{ i=0 } { i++ } END{ print i }" filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ i=0 } { i++ } END{ print i }'</span> filename
|
||||
<span class="token function">awk</span> <span class="token string">"BEGIN{ i=0 } { i++ } END{ print i }"</span> filename
|
||||
</code></pre>
|
||||
<h3 id="awk的工作原理"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk的工作原理"><span class="octicon octicon-link"></span></a>awk的工作原理</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ commands } pattern{ commands } END{ commands }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ commands } pattern{ commands } END{ commands }'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ commands } pattern{ commands } END{ commands }'</span>
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li>第一步:执行<code>BEGIN{ commands }</code>语句块中的语句;</li>
|
||||
|
|
@ -105,24 +111,55 @@
|
|||
<p><strong>END语句块</strong> 在awk从输入流中读取完所有的行 <strong>之后</strong> 即被执行,比如打印所有行的分析结果这类信息汇总都是在END语句块中完成,它也是一个可选语句块。</p>
|
||||
<p><strong>pattern语句块</strong> 中的通用命令是最重要的部分,它也是可选的。如果没有提供pattern语句块,则默认执行<code>{ print }</code>,即打印每一个读取到的行,awk读取的每一行都会执行该语句块。</p>
|
||||
<p><strong>示例</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"A line 1<span class="token entity" title="\n">\n</span>A line 2"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'BEGIN{ print "Start" } { print } END{ print "End" }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo -e "A line 1\nA line 2" | awk 'BEGIN{ print "Start" } { print } END{ print "End" }'
|
||||
Start
|
||||
A line 1
|
||||
A line 2
|
||||
End
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"A line 1<span class="token entity" title="\n">\n</span>A line 2"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'BEGIN{ print "Start" } { print } END{ print "End" }'</span>
|
||||
Start
|
||||
A line <span class="token number">1</span>
|
||||
A line <span class="token number">2</span>
|
||||
End
|
||||
</code></pre>
|
||||
<p>当使用不带参数的<code>print</code>时,它就打印当前行,当<code>print</code>的参数是以逗号进行分隔时,打印时则以空格作为定界符。在awk的print语句块中双引号是被当作拼接符使用,例如:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ var1="v1"; var2="v2"; var3="v3"; print var1,var2,var3; }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo | awk '{ var1="v1"; var2="v2"; var3="v3"; print var1,var2,var3; }'
|
||||
v1 v2 v3
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ var1="v1"; var2="v2"; var3="v3"; print var1,var2,var3; }'</span>
|
||||
v1 v2 v3
|
||||
</code></pre>
|
||||
<p>双引号拼接使用:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ var1="v1"; var2="v2"; var3="v3"; print var1"="var2"="var3; }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo | awk '{ var1="v1"; var2="v2"; var3="v3"; print var1"="var2"="var3; }'
|
||||
v1=v2=v3
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ var1="v1"; var2="v2"; var3="v3"; print var1"="var2"="var3; }'</span>
|
||||
<span class="token assign-left variable">v1</span><span class="token operator">=</span>v2<span class="token operator">=</span>v3
|
||||
</code></pre>
|
||||
<p>{ }类似一个循环体,会对文件中的每一行进行迭代,通常变量初始化语句(如:i=0)以及打印文件头部的语句放入BEGIN语句块中,将打印的结果等语句放在END语句块中。</p>
|
||||
<h2 id="awk内置变量预定义变量"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk内置变量预定义变量"><span class="octicon octicon-link"></span></a>awk内置变量(预定义变量)</h2>
|
||||
<p>说明:[A][N][P][G]表示第一个支持变量的工具,[A]=awk、[N]=nawk、[P]=POSIXawk、[G]=gawk</p>
|
||||
<pre class="language-shell"><code class="language-shell"> **<span class="token variable">$n</span>** 当前记录的第n个字段,比如n为1表示第一个字段,n为2表示第二个字段。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code=" **$n** 当前记录的第n个字段,比如n为1表示第一个字段,n为2表示第二个字段。
|
||||
**$0** 这个变量包含执行过程中当前行的文本内容。
|
||||
[N] **ARGC** 命令行参数的数目。
|
||||
[G] **ARGIND** 命令行中当前文件的位置(从0开始算)。
|
||||
[N] **ARGV** 包含命令行参数的数组。
|
||||
[G] **CONVFMT** 数字转换格式(默认值为%.6g)。
|
||||
[P] **ENVIRON** 环境变量关联数组。
|
||||
[N] **ERRNO** 最后一个系统错误的描述。
|
||||
[G] **FIELDWIDTHS** 字段宽度列表(用空格键分隔)。
|
||||
[A] **FILENAME** 当前输入文件的名。
|
||||
[P] **FNR** 同NR,但相对于当前文件。
|
||||
[A] **FS** 字段分隔符(默认是任何空格)。
|
||||
[G] **IGNORECASE** 如果为真,则进行忽略大小写的匹配。
|
||||
[A] **NF** 表示字段数,在执行过程中对应于当前的字段数。
|
||||
[A] **NR** 表示记录数,在执行过程中对应于当前的行号。
|
||||
[A] **OFMT** 数字的输出格式(默认值是%.6g)。
|
||||
[A] **OFS** 输出字段分隔符(默认值是一个空格)。
|
||||
[A] **ORS** 输出记录分隔符(默认值是一个换行符)。
|
||||
[A] **RS** 记录分隔符(默认是一个换行符)。
|
||||
[N] **RSTART** 由match函数所匹配的字符串的第一个位置。
|
||||
[N] **RLENGTH** 由match函数所匹配的字符串的长度。
|
||||
[N] **SUBSEP** 数组下标分隔符(默认值是34)。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"> **<span class="token variable">$n</span>** 当前记录的第n个字段,比如n为1表示第一个字段,n为2表示第二个字段。
|
||||
**<span class="token variable">$0</span>** 这个变量包含执行过程中当前行的文本内容。
|
||||
<span class="token punctuation">[</span>N<span class="token punctuation">]</span> **ARGC** 命令行参数的数目。
|
||||
<span class="token punctuation">[</span>G<span class="token punctuation">]</span> **ARGIND** 命令行中当前文件的位置(从0开始算)。
|
||||
|
|
@ -146,7 +183,14 @@ v1 v2 v3
|
|||
<span class="token punctuation">[</span>N<span class="token punctuation">]</span> **SUBSEP** 数组下标分隔符(默认值是34)。
|
||||
</code></pre>
|
||||
<p>转义序列</p>
|
||||
<pre><code>\\ \自身
|
||||
<pre><div onclick="copied(this)" data-code="\\ \自身
|
||||
\$ 转义$
|
||||
\t 制表符
|
||||
\b 退格符
|
||||
\r 回车符
|
||||
\n 换行符
|
||||
\c 取消换行
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>\\ \自身
|
||||
\$ 转义$
|
||||
\t 制表符
|
||||
\b 退格符
|
||||
|
|
@ -155,30 +199,52 @@ v1 v2 v3
|
|||
\c 取消换行
|
||||
</code></pre>
|
||||
<p><strong>示例</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span>line2 f4 f5<span class="token entity" title="\n">\n</span>line3 f6 f7"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print "Line No:"NR", No of fields:"NF, "$0="$0, "$1="$1, "$2="$2, "$3="$3}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo -e "line1 f2 f3\nline2 f4 f5\nline3 f6 f7" | awk '{print "Line No:"NR", No of fields:"NF, "$0="$0, "$1="$1, "$2="$2, "$3="$3}'
|
||||
Line No:1, No of fields:3 $0=line1 f2 f3 $1=line1 $2=f2 $3=f3
|
||||
Line No:2, No of fields:3 $0=line2 f4 f5 $1=line2 $2=f4 $3=f5
|
||||
Line No:3, No of fields:3 $0=line3 f6 f7 $1=line3 $2=f6 $3=f7
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span>line2 f4 f5<span class="token entity" title="\n">\n</span>line3 f6 f7"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print "Line No:"NR", No of fields:"NF, "$0="$0, "$1="$1, "$2="$2, "$3="$3}'</span>
|
||||
Line No:1, No of fields:3 <span class="token variable">$0</span><span class="token operator">=</span>line1 f2 f3 <span class="token variable">$1</span><span class="token operator">=</span>line1 <span class="token variable">$2</span><span class="token operator">=</span>f2 <span class="token variable">$3</span><span class="token operator">=</span>f3
|
||||
Line No:2, No of fields:3 <span class="token variable">$0</span><span class="token operator">=</span>line2 f4 f5 <span class="token variable">$1</span><span class="token operator">=</span>line2 <span class="token variable">$2</span><span class="token operator">=</span>f4 <span class="token variable">$3</span><span class="token operator">=</span>f5
|
||||
Line No:3, No of fields:3 <span class="token variable">$0</span><span class="token operator">=</span>line3 f6 f7 <span class="token variable">$1</span><span class="token operator">=</span>line3 <span class="token variable">$2</span><span class="token operator">=</span>f6 <span class="token variable">$3</span><span class="token operator">=</span>f7
|
||||
</code></pre>
|
||||
<p>使用<code>print $NF</code>可以打印出一行中的最后一个字段,使用<code>$(NF-1)</code>则是打印倒数第二个字段,其他以此类推:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span> line2 f4 f5"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $NF}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo -e "line1 f2 f3\n line2 f4 f5" | awk '{print $NF}'
|
||||
f3
|
||||
f5
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span> line2 f4 f5"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $NF}'</span>
|
||||
f3
|
||||
f5
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span> line2 f4 f5"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $(NF-1)}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo -e "line1 f2 f3\n line2 f4 f5" | awk '{print $(NF-1)}'
|
||||
f2
|
||||
f4
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> -e <span class="token string">"line1 f2 f3<span class="token entity" title="\n">\n</span> line2 f4 f5"</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{print $(NF-1)}'</span>
|
||||
f2
|
||||
f4
|
||||
|
||||
</code></pre>
|
||||
<p>打印每一行的第二和第三个字段:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'{ print $2,$3 }'</span> filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk '{ print $2,$3 }' filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'{ print $2,$3 }'</span> filename
|
||||
</code></pre>
|
||||
<p>统计文件中的行数:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'END{ print NR }'</span> filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'END{ print NR }' filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'END{ print NR }'</span> filename
|
||||
</code></pre>
|
||||
<p>以上命令只使用了END语句块,在读入每一行的时,awk会将NR更新为对应的行号,当到达最后一行NR的值就是最后一行的行号,所以END语句块中的NR就是文件的行数。</p>
|
||||
<p>一个每一行中第一个字段值累加的例子:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">seq</span> <span class="token number">5</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'BEGIN{ sum=0; print "总和:" } { print $1"+"; sum+=$1 } END{ print "等于"; print sum }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="seq 5 | awk 'BEGIN{ sum=0; print "总和:" } { print $1"+"; sum+=$1 } END{ print "等于"; print sum }'
|
||||
总和:
|
||||
1+
|
||||
2+
|
||||
3+
|
||||
4+
|
||||
5+
|
||||
等于
|
||||
15
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">seq</span> <span class="token number">5</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'BEGIN{ sum=0; print "总和:" } { print $1"+"; sum+=$1 } END{ print "等于"; print sum }'</span>
|
||||
总和:
|
||||
<span class="token number">1</span>+
|
||||
<span class="token number">2</span>+
|
||||
|
|
@ -190,20 +256,27 @@ f4
|
|||
</code></pre>
|
||||
<h2 id="将外部变量值传递给awk"><a class="anchor" aria-hidden="true" tabindex="-1" href="#将外部变量值传递给awk"><span class="octicon octicon-link"></span></a>将外部变量值传递给awk</h2>
|
||||
<p>借助 <strong><code>-v</code>选项</strong> ,可以将外部值(并非来自stdin)传递给awk:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable">VAR</span><span class="token operator">=</span><span class="token number">10000</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="VAR=10000
|
||||
echo | awk -v VARIABLE=$VAR '{ print VARIABLE }'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable">VAR</span><span class="token operator">=</span><span class="token number">10000</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> -v <span class="token assign-left variable">VARIABLE</span><span class="token operator">=</span><span class="token variable">$VAR</span> <span class="token string">'{ print VARIABLE }'</span>
|
||||
</code></pre>
|
||||
<p>另一种传递外部变量方法:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable">var1</span><span class="token operator">=</span><span class="token string">"aaa"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="var1="aaa"
|
||||
var2="bbb"
|
||||
echo | awk '{ print v1,v2 }' v1=$var1 v2=$var2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable">var1</span><span class="token operator">=</span><span class="token string">"aaa"</span>
|
||||
<span class="token assign-left variable">var2</span><span class="token operator">=</span><span class="token string">"bbb"</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ print v1,v2 }'</span> <span class="token assign-left variable">v1</span><span class="token operator">=</span><span class="token variable">$var1</span> <span class="token assign-left variable">v2</span><span class="token operator">=</span><span class="token variable">$var2</span>
|
||||
</code></pre>
|
||||
<p>当输入来自于文件时使用:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'{ print v1,v2 }'</span> <span class="token assign-left variable">v1</span><span class="token operator">=</span><span class="token variable">$var1</span> <span class="token assign-left variable">v2</span><span class="token operator">=</span><span class="token variable">$var2</span> filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk '{ print v1,v2 }' v1=$var1 v2=$var2 filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'{ print v1,v2 }'</span> <span class="token assign-left variable">v1</span><span class="token operator">=</span><span class="token variable">$var1</span> <span class="token assign-left variable">v2</span><span class="token operator">=</span><span class="token variable">$var2</span> filename
|
||||
</code></pre>
|
||||
<p>以上方法中,变量之间用空格分隔作为awk的命令行参数跟随在BEGIN、{}和END语句块之后。</p>
|
||||
<h2 id="查找进程pid"><a class="anchor" aria-hidden="true" tabindex="-1" href="#查找进程pid"><span class="octicon octicon-link"></span></a>查找进程pid</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">netstat</span> -antup <span class="token operator">|</span> <span class="token function">grep</span> <span class="token number">7770</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ print $NF NR}'</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ print $1}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="netstat -antup | grep 7770 | awk '{ print $NF NR}' | awk '{ print $1}'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">netstat</span> -antup <span class="token operator">|</span> <span class="token function">grep</span> <span class="token number">7770</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ print $NF NR}'</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{ print $1}'</span>
|
||||
</code></pre>
|
||||
<h2 id="awk运算与判断"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk运算与判断"><span class="octicon octicon-link"></span></a>awk运算与判断</h2>
|
||||
<p>作为一种程序设计语言所应具有的特点之一,awk支持多种运算,这些运算与C语言提供的基本相同。awk还提供了一系列内置的运算函数(如log、sqr、cos、sin等)和一些用于对字符串进行操作(运算)的函数(如length、substr等等)。这些函数的引用大大的提高了awk的运算功能。作为对条件转移指令的一部分,关系判断是每种程序设计语言都具备的功能,awk也不例外,awk中允许进行多种测试,作为样式匹配,还提供了模式匹配表达式~(匹配)和!~(不匹配)。作为对测试的一种扩充,awk也支持用逻辑运算符。</p>
|
||||
|
|
@ -239,7 +312,9 @@ f4
|
|||
</tbody>
|
||||
</table>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";print a++,++a;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a="b";print a++,++a;}'
|
||||
0 2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";print a++,++a;}'</span>
|
||||
<span class="token number">0</span> <span class="token number">2</span>
|
||||
</code></pre>
|
||||
<p>注意:所有用作算术运算符进行操作,操作数自动转为数值,所有非数值都变为0</p>
|
||||
|
|
@ -259,7 +334,8 @@ f4
|
|||
</tbody>
|
||||
</table>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable">a</span><span class="token operator">+=</span><span class="token number">5</span><span class="token punctuation">;</span> 等价于:a<span class="token operator">=</span>a+5<span class="token punctuation">;</span> 其它同类
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="a+=5; 等价于:a=a+5; 其它同类
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable">a</span><span class="token operator">+=</span><span class="token number">5</span><span class="token punctuation">;</span> 等价于:a<span class="token operator">=</span>a+5<span class="token punctuation">;</span> 其它同类
|
||||
</code></pre>
|
||||
<h3 id="逻辑运算符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#逻辑运算符"><span class="octicon octicon-link"></span></a>逻辑运算符</h3>
|
||||
<table>
|
||||
|
|
@ -281,7 +357,9 @@ f4
|
|||
</tbody>
|
||||
</table>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a=1;b=2;print (a>5 && b<=2),(a>5 || b<=2);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a=1;b=2;print (a>5 && b<=2),(a>5 || b<=2);}'
|
||||
0 1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a=1;b=2;print (a>5 && b<=2),(a>5 || b<=2);}'</span>
|
||||
<span class="token number">0</span> <span class="token number">1</span>
|
||||
</code></pre>
|
||||
<h3 id="正则运算符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#正则运算符"><span class="octicon octicon-link"></span></a>正则运算符</h3>
|
||||
|
|
@ -299,7 +377,21 @@ f4
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre><code>^ 行首
|
||||
<pre><div onclick="copied(this)" data-code="^ 行首
|
||||
$ 行尾
|
||||
. 除了换行符以外的任意单个字符
|
||||
* 前导字符的零个或多个
|
||||
.* 所有字符
|
||||
[] 字符组内的任一字符
|
||||
[^]对字符组内的每个字符取反(不匹配字符组内的每个字符)
|
||||
^[^] 非字符组内的字符开头的行
|
||||
[a-z] 小写字母
|
||||
[A-Z] 大写字母
|
||||
[a-Z] 小写和大写字母
|
||||
[0-9] 数字
|
||||
\< 单词头单词一般以空格或特殊字符做分隔,连续的字符串被当做单词
|
||||
\> 单词尾
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>^ 行首
|
||||
$ 行尾
|
||||
. 除了换行符以外的任意单个字符
|
||||
* 前导字符的零个或多个
|
||||
|
|
@ -318,7 +410,9 @@ $ 行尾
|
|||
<p>正则需要用 /正则/ 包围住</p>
|
||||
</blockquote>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="100testa";if(a ~ /^100*/){print "ok";}}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a="100testa";if(a ~ /^100*/){print "ok";}}'
|
||||
ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="100testa";if(a ~ /^100*/){print "ok";}}'</span>
|
||||
ok
|
||||
</code></pre>
|
||||
<h3 id="关系运算符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#关系运算符"><span class="octicon octicon-link"></span></a>关系运算符</h3>
|
||||
|
|
@ -337,7 +431,9 @@ ok
|
|||
</tbody>
|
||||
</table>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a=11;if(a >= 9){print "ok";}}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a=11;if(a >= 9){print "ok";}}'
|
||||
ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a=11;if(a >= 9){print "ok";}}'</span>
|
||||
ok
|
||||
</code></pre>
|
||||
<p>注意:> < 可以作为字符串比较,也可以用作数值比较,关键看操作数如果是字符串就会转换为字符串比较。两个都为数字才转为数值比较。字符串比较:按照ASCII码顺序比较。</p>
|
||||
|
|
@ -369,13 +465,19 @@ ok
|
|||
</tbody>
|
||||
</table>
|
||||
<p>例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";print a=="b"?"ok":"err";}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a="b";print a=="b"?"ok":"err";}'
|
||||
ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";print a=="b"?"ok":"err";}'</span>
|
||||
ok
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";arr[0]="b";arr[1]="c";print (a in arr);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{a="b";arr[0]="b";arr[1]="c";print (a in arr);}'
|
||||
0
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{a="b";arr[0]="b";arr[1]="c";print (a in arr);}'</span>
|
||||
<span class="token number">0</span>
|
||||
</code></pre>
|
||||
<pre><code>awk 'BEGIN{a="b";arr[0]="b";arr["b"]="c";print (a in arr);}'
|
||||
<pre><div onclick="copied(this)" data-code="awk 'BEGIN{a="b";arr[0]="b";arr["b"]="c";print (a in arr);}'
|
||||
1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>awk 'BEGIN{a="b";arr[0]="b";arr["b"]="c";print (a in arr);}'
|
||||
1
|
||||
</code></pre>
|
||||
<h3 id="运算级优先级表"><a class="anchor" aria-hidden="true" tabindex="-1" href="#运算级优先级表"><span class="octicon octicon-link"></span></a>运算级优先级表</h3>
|
||||
|
|
@ -383,7 +485,17 @@ ok
|
|||
<h2 id="awk高级输入输出"><a class="anchor" aria-hidden="true" tabindex="-1" href="#awk高级输入输出"><span class="octicon octicon-link"></span></a>awk高级输入输出</h2>
|
||||
<h3 id="读取下一条记录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#读取下一条记录"><span class="octicon octicon-link"></span></a>读取下一条记录</h3>
|
||||
<p>awk中<code>next</code>语句使用:在循环逐行匹配,如果遇到next,就会跳过当前行,直接忽略下面语句。而进行下一行匹配。next语句一般用于多行合并:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> text.txt
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat text.txt
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
e
|
||||
|
||||
awk 'NR%2==1{next}{print NR,$0;}' text.txt
|
||||
2 b
|
||||
4 d
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> text.txt
|
||||
a
|
||||
b
|
||||
c
|
||||
|
|
@ -396,7 +508,27 @@ e
|
|||
</code></pre>
|
||||
<p>当记录行号除以2余1,就跳过当前行。下面的<code>print NR,$0</code>也不会执行。下一行开始,程序有开始判断<code>NR%2</code>值。这个时候记录行号是<code>:2</code> ,就会执行下面语句块:<code>'print NR,$0'</code></p>
|
||||
<p>分析发现需要将包含有“web”行进行跳过,然后需要将内容与下面行合并为一行:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> text.txt
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat text.txt
|
||||
web01[192.168.2.100]
|
||||
httpd ok
|
||||
tomcat ok
|
||||
sendmail ok
|
||||
web02[192.168.2.101]
|
||||
httpd ok
|
||||
postfix ok
|
||||
web03[192.168.2.102]
|
||||
mysqld ok
|
||||
httpd ok
|
||||
0
|
||||
awk '/^web/{T=$0;next;}{print T":"t,$0;}' text.txt
|
||||
web01[192.168.2.100]: httpd ok
|
||||
web01[192.168.2.100]: tomcat ok
|
||||
web01[192.168.2.100]: sendmail ok
|
||||
web02[192.168.2.101]: httpd ok
|
||||
web02[192.168.2.101]: postfix ok
|
||||
web03[192.168.2.102]: mysqld ok
|
||||
web03[192.168.2.102]: httpd ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> text.txt
|
||||
web01<span class="token punctuation">[</span><span class="token number">192.168</span>.2.100<span class="token punctuation">]</span>
|
||||
httpd ok
|
||||
tomcat ok
|
||||
|
|
@ -427,28 +559,38 @@ web03<span class="token punctuation">[</span><span class="token number">192.168<
|
|||
</ul>
|
||||
<p><strong>示例:</strong></p>
|
||||
<p>执行linux的<code>date</code>命令,并通过管道输出给<code>getline</code>,然后再把输出赋值给自定义变量out,并打印它:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ "date" | getline out; print out }'</span> <span class="token builtin class-name">test</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ "date" | getline out; print out }' test
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ "date" | getline out; print out }'</span> <span class="token builtin class-name">test</span>
|
||||
</code></pre>
|
||||
<p>执行shell的date命令,并通过管道输出给getline,然后getline从管道中读取并将输入赋值给out,split函数把变量out转化成数组mon,然后打印数组mon的第二个元素:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ "date" | getline out; split(out,mon); print mon[2] }'</span> <span class="token builtin class-name">test</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ "date" | getline out; split(out,mon); print mon[2] }' test
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ "date" | getline out; split(out,mon); print mon[2] }'</span> <span class="token builtin class-name">test</span>
|
||||
</code></pre>
|
||||
<p>命令ls的输出传递给geline作为输入,循环使getline从ls的输出中读取一行,并把它打印到屏幕。这里没有输入文件,因为BEGIN块在打开输入文件前执行,所以可以忽略输入文件。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ while( "ls" | getline) print }'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{ while( "ls" | getline) print }'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{ while( "ls" | getline) print }'</span>
|
||||
</code></pre>
|
||||
<h3 id="关闭文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#关闭文件"><span class="octicon octicon-link"></span></a>关闭文件</h3>
|
||||
<p>awk中允许在程序中关闭一个输入或输出文件,方法是使用awk的close语句。</p>
|
||||
<pre class="language-shell"><code class="language-shell">close<span class="token punctuation">(</span><span class="token string">"filename"</span><span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="close("filename")
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">close<span class="token punctuation">(</span><span class="token string">"filename"</span><span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<p>filename可以是getline打开的文件,也可以是stdin,包含文件名的变量或者getline使用的确切命令。或一个输出文件,可以是stdout,包含文件名的变量或使用管道的确切命令。</p>
|
||||
<h3 id="输出到一个文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#输出到一个文件"><span class="octicon octicon-link"></span></a>输出到一个文件</h3>
|
||||
<p>awk中允许用如下方式将结果输出到一个文件:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{printf("hello word!n") > "datafile"}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo | awk '{printf("hello word!n") > "datafile"}'
|
||||
# 或
|
||||
echo | awk '{printf("hello word!n") >> "datafile"}'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{printf("hello word!n") > "datafile"}'</span>
|
||||
<span class="token comment"># 或</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token operator">|</span> <span class="token function">awk</span> <span class="token string">'{printf("hello word!n") >> "datafile"}'</span>
|
||||
</code></pre>
|
||||
<h2 id="设置字段定界符"><a class="anchor" aria-hidden="true" tabindex="-1" href="#设置字段定界符"><span class="octicon octicon-link"></span></a>设置字段定界符</h2>
|
||||
<p>默认的字段定界符是空格,可以使用<code>-F "定界符"</code> 明确指定一个定界符:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> -F: <span class="token string">'{ print $NF }'</span> /etc/passwd
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk -F: '{ print $NF }' /etc/passwd
|
||||
# 或
|
||||
awk 'BEGIN{ FS=":" } { print $NF }' /etc/passwd
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> -F: <span class="token string">'{ print $NF }'</span> /etc/passwd
|
||||
<span class="token comment"># 或</span>
|
||||
<span class="token function">awk</span> <span class="token string">'BEGIN{ FS=":" } { print $NF }'</span> /etc/passwd
|
||||
</code></pre>
|
||||
|
|
@ -456,13 +598,23 @@ web03<span class="token punctuation">[</span><span class="token number">192.168<
|
|||
<h2 id="流程控制语句"><a class="anchor" aria-hidden="true" tabindex="-1" href="#流程控制语句"><span class="octicon octicon-link"></span></a>流程控制语句</h2>
|
||||
<p>在linux awk的while、do-while和for语句中允许使用break,continue语句来控制流程走向,也允许使用exit这样的语句来退出。break中断当前正在执行的循环并跳到循环外执行下一条语句。if 是流程选择用法。awk中,流程控制语句,语法结构,与c语言类型。有了这些语句,其实很多shell程序都可以交给awk,而且性能是非常快的。下面是各个语句用法。</p>
|
||||
<h3 id="条件判断语句"><a class="anchor" aria-hidden="true" tabindex="-1" href="#条件判断语句"><span class="octicon octicon-link"></span></a>条件判断语句</h3>
|
||||
<pre class="language-shell"><code class="language-shell">if<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="if(表达式)
|
||||
语句1
|
||||
else
|
||||
语句2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">if<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
语句1
|
||||
<span class="token keyword">else</span>
|
||||
语句2
|
||||
</code></pre>
|
||||
<p>格式中语句1可以是多个语句,为了方便判断和阅读,最好将多个语句用{}括起来。awk分枝结构允许嵌套,其格式为:</p>
|
||||
<pre class="language-shell"><code class="language-shell">if<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="if(表达式)
|
||||
{语句1}
|
||||
else if(表达式)
|
||||
{语句2}
|
||||
else
|
||||
{语句3}
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">if<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<span class="token punctuation">{</span>语句1<span class="token punctuation">}</span>
|
||||
<span class="token keyword">else</span> if<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<span class="token punctuation">{</span>语句2<span class="token punctuation">}</span>
|
||||
|
|
@ -470,7 +622,21 @@ web03<span class="token punctuation">[</span><span class="token number">192.168<
|
|||
<span class="token punctuation">{</span>语句3<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>示例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
test=100;
|
||||
if(test>90){
|
||||
print "very good";
|
||||
}
|
||||
else if(test>60){
|
||||
print "good";
|
||||
}
|
||||
else{
|
||||
print "no pass";
|
||||
}
|
||||
}'
|
||||
|
||||
very good
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
test=100;
|
||||
if(test>90){
|
||||
print "very good";
|
||||
|
|
@ -488,11 +654,23 @@ very good
|
|||
<p>每条命令语句后面可以用<code>;</code> <strong>分号</strong> 结尾。</p>
|
||||
<h3 id="循环语句"><a class="anchor" aria-hidden="true" tabindex="-1" href="#循环语句"><span class="octicon octicon-link"></span></a>循环语句</h3>
|
||||
<h3 id="-while语句"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-while语句"><span class="octicon octicon-link"></span></a># while语句</h3>
|
||||
<pre class="language-shell"><code class="language-shell">while<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="while(表达式)
|
||||
{语句}
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">while<span class="token punctuation">(</span>表达式<span class="token punctuation">)</span>
|
||||
<span class="token punctuation">{</span>语句<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>示例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
test=100;
|
||||
total=0;
|
||||
while(i<=test){
|
||||
total+=i;
|
||||
i++;
|
||||
}
|
||||
print total;
|
||||
}'
|
||||
5050
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
test=100;
|
||||
total=0;
|
||||
while(i<=test){
|
||||
|
|
@ -506,11 +684,27 @@ print total;
|
|||
<h3 id="-for循环"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-for循环"><span class="octicon octicon-link"></span></a># for循环</h3>
|
||||
<p>for循环有两种格式:</p>
|
||||
<p>格式1:</p>
|
||||
<pre class="language-shell"><code class="language-shell">for<span class="token punctuation">(</span>变量 <span class="token keyword">in</span> 数组<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="for(变量 in 数组)
|
||||
{语句}
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">for<span class="token punctuation">(</span>变量 <span class="token keyword">in</span> 数组<span class="token punctuation">)</span>
|
||||
<span class="token punctuation">{</span>语句<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>示例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
for(k in ENVIRON){
|
||||
print k"="ENVIRON[k];
|
||||
}
|
||||
|
||||
}'
|
||||
TERM=linux
|
||||
G_BROKEN_FILENAMES=1
|
||||
SHLVL=1
|
||||
pwd=/root/text
|
||||
...
|
||||
logname=root
|
||||
HOME=/root
|
||||
SSH_CLIENT=192.168.1.21 53087 22
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
for(k in ENVIRON){
|
||||
print k"="ENVIRON[k];
|
||||
}
|
||||
|
|
@ -527,11 +721,21 @@ for(k in ENVIRON){
|
|||
</code></pre>
|
||||
<p>注:ENVIRON是awk常量,是子典型数组。</p>
|
||||
<p>格式2:</p>
|
||||
<pre class="language-shell"><code class="language-shell">for<span class="token punctuation">(</span>变量<span class="token punctuation">;</span>条件<span class="token punctuation">;</span>表达式<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="for(变量;条件;表达式)
|
||||
{语句}
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">for<span class="token punctuation">(</span>变量<span class="token punctuation">;</span>条件<span class="token punctuation">;</span>表达式<span class="token punctuation">)</span>
|
||||
<span class="token punctuation">{</span>语句<span class="token punctuation">}</span>
|
||||
</code></pre>
|
||||
<p>示例:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
total=0;
|
||||
for(i=0;i<=100;i++){
|
||||
total+=i;
|
||||
}
|
||||
print total;
|
||||
}'
|
||||
5050
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
total=0;
|
||||
for(i=0;i<=100;i++){
|
||||
total+=i;
|
||||
|
|
@ -541,11 +745,20 @@ print total;
|
|||
<span class="token number">5050</span>
|
||||
</code></pre>
|
||||
<h3 id="-do循环"><a class="anchor" aria-hidden="true" tabindex="-1" href="#-do循环"><span class="octicon octicon-link"></span></a># do循环</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token keyword">do</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="do
|
||||
{语句} while(条件)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token keyword">do</span>
|
||||
<span class="token punctuation">{</span>语句<span class="token punctuation">}</span> while<span class="token punctuation">(</span>条件<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<p>例子:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
total=0;
|
||||
i=0;
|
||||
do {total+=i;i++;} while(i<=100)
|
||||
print total;
|
||||
}'
|
||||
5050
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
total=0;
|
||||
i=0;
|
||||
do {total+=i;i++;} while(i<=100)
|
||||
|
|
@ -564,38 +777,59 @@ do {total+=i;i++;} while(i<=100)
|
|||
<p>数组是awk的灵魂,处理文本中最不能少的就是它的数组处理。因为数组索引(下标)可以是数字和字符串在awk中数组叫做关联数组(associative arrays)。awk 中的数组不必提前声明,也不必声明大小。数组元素用0或空字符串来初始化,这根据上下文而定。</p>
|
||||
<h3 id="数组的定义"><a class="anchor" aria-hidden="true" tabindex="-1" href="#数组的定义"><span class="octicon octicon-link"></span></a>数组的定义</h3>
|
||||
<p>数字做数组索引(下标):</p>
|
||||
<pre class="language-shell"><code class="language-shell">Array<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"sun"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="Array[1]="sun"
|
||||
Array[2]="kai"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">Array<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"sun"</span>
|
||||
Array<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"kai"</span>
|
||||
</code></pre>
|
||||
<p>字符串做数组索引(下标):</p>
|
||||
<pre class="language-shell"><code class="language-shell">Array<span class="token punctuation">[</span><span class="token string">"first"</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"www"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="Array["first"]="www"
|
||||
Array"[last"]="name"
|
||||
Array["birth"]="1987"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">Array<span class="token punctuation">[</span><span class="token string">"first"</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"www"</span>
|
||||
Array<span class="token string">"[last"</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"name"</span>
|
||||
Array<span class="token punctuation">[</span><span class="token string">"birth"</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token string">"1987"</span>
|
||||
</code></pre>
|
||||
<p>使用中<code>print Array[1]</code>会打印出sun;使用<code>print Array[2]</code>会打印出kai;使用<code>print["birth"]</code>会得到1987。</p>
|
||||
<p><strong>读取数组的值</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">{</span> for<span class="token punctuation">(</span>item <span class="token keyword">in</span> array<span class="token punctuation">)</span> <span class="token punctuation">{</span>print array<span class="token punctuation">[</span>item<span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment">#输出的顺序是随机的</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="{ for(item in array) {print array[item]}; } #输出的顺序是随机的
|
||||
{ for(i=1;i<=len;i++) {print array[i]}; } #Len是数组的长度
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">{</span> for<span class="token punctuation">(</span>item <span class="token keyword">in</span> array<span class="token punctuation">)</span> <span class="token punctuation">{</span>print array<span class="token punctuation">[</span>item<span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment">#输出的顺序是随机的</span>
|
||||
<span class="token punctuation">{</span> for<span class="token punctuation">(</span>i<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>i<span class="token operator"><=</span>len<span class="token punctuation">;</span>i++<span class="token punctuation">)</span> <span class="token punctuation">{</span>print array<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">}</span><span class="token punctuation">;</span> <span class="token punctuation">}</span> <span class="token comment">#Len是数组的长度</span>
|
||||
</code></pre>
|
||||
<h3 id="数组相关函数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#数组相关函数"><span class="octicon octicon-link"></span></a>数组相关函数</h3>
|
||||
<p><strong>得到数组长度:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";lens=split(info,tA," ");print length(tA),lens;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="it is a test";lens=split(info,tA," ");print length(tA),lens;}'
|
||||
4 4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";lens=split(info,tA," ");print length(tA),lens;}'</span>
|
||||
<span class="token number">4</span> <span class="token number">4</span>
|
||||
</code></pre>
|
||||
<p>length返回字符串以及数组长度,split进行分割字符串为数组,也会返回分割得到数组长度。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";split(info,tA," ");print asort(tA);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="it is a test";split(info,tA," ");print asort(tA);}'
|
||||
4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";split(info,tA," ");print asort(tA);}'</span>
|
||||
<span class="token number">4</span>
|
||||
</code></pre>
|
||||
<p>asort对数组进行排序,返回数组长度。</p>
|
||||
<p><strong>输出数组内容(无序,有序输出):</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";split(info,tA," ");for(k in tA){print k,tA[k];}}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="it is a test";split(info,tA," ");for(k in tA){print k,tA[k];}}'
|
||||
4 test
|
||||
1 it
|
||||
2 is
|
||||
3 a
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";split(info,tA," ");for(k in tA){print k,tA[k];}}'</span>
|
||||
<span class="token number">4</span> <span class="token builtin class-name">test</span>
|
||||
<span class="token number">1</span> it
|
||||
<span class="token number">2</span> is
|
||||
<span class="token number">3</span> a
|
||||
</code></pre>
|
||||
<p><code>for…in</code>输出,因为数组是关联数组,默认是无序的。所以通过<code>for…in</code>得到是无序的数组。如果需要得到有序数组,需要通过下标获得。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";tlen=split(info,tA," ");for(k=1;k<=tlen;k++){print k,tA[k];}}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="it is a test";tlen=split(info,tA," ");for(k=1;k<=tlen;k++){print k,tA[k];}}'
|
||||
1 it
|
||||
2 is
|
||||
3 a
|
||||
4 test
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="it is a test";tlen=split(info,tA," ");for(k=1;k<=tlen;k++){print k,tA[k];}}'</span>
|
||||
<span class="token number">1</span> it
|
||||
<span class="token number">2</span> is
|
||||
<span class="token number">3</span> a
|
||||
|
|
@ -603,7 +837,13 @@ Array<span class="token punctuation">[</span><span class="token string">"birth"<
|
|||
</code></pre>
|
||||
<p>注意:数组下标是从1开始,与C数组不一样。</p>
|
||||
<p><strong>判断键值存在以及删除键值:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 错误的判断方法:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 错误的判断方法:
|
||||
awk 'BEGIN{tB["a"]="a1";tB["b"]="b1";if(tB["c"]!="1"){print "no found";};for(k in tB){print k,tB[k];}}'
|
||||
no found
|
||||
a a1
|
||||
b b1
|
||||
c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 错误的判断方法:</span>
|
||||
<span class="token function">awk</span> <span class="token string">'BEGIN{tB["a"]="a1";tB["b"]="b1";if(tB["c"]!="1"){print "no found";};for(k in tB){print k,tB[k];}}'</span>
|
||||
no found
|
||||
a a1
|
||||
|
|
@ -611,13 +851,20 @@ b b1
|
|||
c
|
||||
</code></pre>
|
||||
<p>以上出现奇怪问题,<code>tB[“c”]</code>没有定义,但是循环时候,发现已经存在该键值,它的值为空,这里需要注意,awk数组是关联数组,只要通过数组引用它的key,就会自动创建改序列。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 正确判断方法:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 正确判断方法:
|
||||
awk 'BEGIN{tB["a"]="a1";tB["b"]="b1";if( "c" in tB){print "ok";};for(k in tB){print k,tB[k];}}'
|
||||
a a1
|
||||
b b1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 正确判断方法:</span>
|
||||
<span class="token function">awk</span> <span class="token string">'BEGIN{tB["a"]="a1";tB["b"]="b1";if( "c" in tB){print "ok";};for(k in tB){print k,tB[k];}}'</span>
|
||||
a a1
|
||||
b b1
|
||||
</code></pre>
|
||||
<p><code>if(key in array)</code>通过这种方法判断数组中是否包含<code>key</code>键值。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment">#删除键值:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="#删除键值:
|
||||
awk 'BEGIN{tB["a"]="a1";tB["b"]="b1";delete tB["a"];for(k in tB){print k,tB[k];}}'
|
||||
b b1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment">#删除键值:</span>
|
||||
<span class="token function">awk</span> <span class="token string">'BEGIN{tB["a"]="a1";tB["b"]="b1";delete tB["a"];for(k in tB){print k,tB[k];}}'</span>
|
||||
b b1
|
||||
</code></pre>
|
||||
|
|
@ -625,7 +872,25 @@ b b1
|
|||
<h3 id="二维多维数组使用"><a class="anchor" aria-hidden="true" tabindex="-1" href="#二维多维数组使用"><span class="octicon octicon-link"></span></a>二维、多维数组使用</h3>
|
||||
<p>awk的多维数组在本质上是一维数组,更确切一点,awk在存储上并不支持多维数组。awk提供了逻辑上模拟二维数组的访问方式。例如,<code>array[2,4]=1</code>这样的访问是允许的。awk使用一个特殊的字符串<code>SUBSEP(<28>34)</code>作为分割字段,在上面的例子中,关联数组array存储的键值实际上是2<EFBFBD>344。</p>
|
||||
<p>类似一维数组的成员测试,多维数组可以使用<code>if ( (i,j) in array)</code>这样的语法,但是下标必须放置在圆括号中。类似一维数组的循环访问,多维数组使用<code>for ( item in array )</code>这样的语法遍历数组。与一维数组不同的是,多维数组必须使用<code>split()</code>函数来访问单独的下标分量。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
for(i=1;i<=9;i++){
|
||||
for(j=1;j<=9;j++){
|
||||
tarr[i,j]=i*j; print i,"*",j,"=",tarr[i,j];
|
||||
}
|
||||
}
|
||||
}'
|
||||
1 * 1 = 1
|
||||
1 * 2 = 2
|
||||
1 * 3 = 3
|
||||
1 * 4 = 4
|
||||
1 * 5 = 5
|
||||
1 * 6 = 6
|
||||
...
|
||||
9 * 6 = 54
|
||||
9 * 7 = 63
|
||||
9 * 8 = 72
|
||||
9 * 9 = 81
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
for(i=1;i<=9;i++){
|
||||
for(j=1;j<=9;j++){
|
||||
tarr[i,j]=i*j; print i,"*",j,"=",tarr[i,j];
|
||||
|
|
@ -646,7 +911,17 @@ for(i=1;i<=9;i++){
|
|||
</code></pre>
|
||||
<p>可以通过<code>array[k,k2]</code>引用获得数组内容。</p>
|
||||
<p>另一种方法:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{
|
||||
for(i=1;i<=9;i++){
|
||||
for(j=1;j<=9;j++){
|
||||
tarr[i,j]=i*j;
|
||||
}
|
||||
}
|
||||
for(m in tarr){
|
||||
split(m,tarr2,SUBSEP); print tarr2[1],"*",tarr2[2],"=",tarr[m];
|
||||
}
|
||||
}'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{
|
||||
for(i=1;i<=9;i++){
|
||||
for(j=1;j<=9;j++){
|
||||
tarr[i,j]=i*j;
|
||||
|
|
@ -707,13 +982,22 @@ for(m in tarr){
|
|||
</tbody>
|
||||
</table>
|
||||
<p>举例说明:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{OFMT="%.3f";fs=sin(1);fe=exp(10);fl=log(10);fi=int(3.1415);print fs,fe,fl,fi;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{OFMT="%.3f";fs=sin(1);fe=exp(10);fl=log(10);fi=int(3.1415);print fs,fe,fl,fi;}'
|
||||
0.841 22026.466 2.303 3
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{OFMT="%.3f";fs=sin(1);fe=exp(10);fl=log(10);fi=int(3.1415);print fs,fe,fl,fi;}'</span>
|
||||
<span class="token number">0.841</span> <span class="token number">22026.466</span> <span class="token number">2.303</span> <span class="token number">3</span>
|
||||
|
||||
</code></pre>
|
||||
<p>OFMT 设置输出数据格式是保留3位小数。</p>
|
||||
<p>获得随机数:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{srand();fr=int(100*rand());print fr;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{srand();fr=int(100*rand());print fr;}'
|
||||
78
|
||||
awk 'BEGIN{srand();fr=int(100*rand());print fr;}'
|
||||
31
|
||||
awk 'BEGIN{srand();fr=int(100*rand());print fr;}'
|
||||
41
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{srand();fr=int(100*rand());print fr;}'</span>
|
||||
<span class="token number">78</span>
|
||||
<span class="token function">awk</span> <span class="token string">'BEGIN{srand();fr=int(100*rand());print fr;}'</span>
|
||||
<span class="token number">31</span>
|
||||
|
|
@ -777,26 +1061,40 @@ for(m in tarr){
|
|||
</table>
|
||||
<p>注:Ere都可以是正则表达式。</p>
|
||||
<p><strong>gsub,sub使用</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";gsub(/[0-9]+/,"!",info);print info}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="this is a test2010test!";gsub(/[0-9]+/,"!",info);print info}'
|
||||
this is a test!test!
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";gsub(/[0-9]+/,"!",info);print info}'</span>
|
||||
this is a test<span class="token operator">!</span>test<span class="token operator">!</span>
|
||||
</code></pre>
|
||||
<p>在 info中查找满足正则表达式,<code>/[0-9]+/</code> 用<code>””</code>替换,并且替换后的值,赋值给info 未给info值,默认是<code>$0</code></p>
|
||||
<p><strong>查找字符串(index使用)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";print index(info,"test")?"ok":"no found";}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="this is a test2010test!";print index(info,"test")?"ok":"no found";}'
|
||||
ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";print index(info,"test")?"ok":"no found";}'</span>
|
||||
ok
|
||||
</code></pre>
|
||||
<p>未找到,返回0</p>
|
||||
<p><strong>正则表达式匹配查找(match使用)</strong></p>
|
||||
<pre><code>awk 'BEGIN{info="this is a test2010test!";print match(info,/[0-9]+/)?"ok":"no found";}'
|
||||
<pre><div onclick="copied(this)" data-code="awk 'BEGIN{info="this is a test2010test!";print match(info,/[0-9]+/)?"ok":"no found";}'
|
||||
ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>awk 'BEGIN{info="this is a test2010test!";print match(info,/[0-9]+/)?"ok":"no found";}'
|
||||
ok
|
||||
</code></pre>
|
||||
<p><strong>截取字符串(substr使用)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>wangsl@centos5 ~<span class="token punctuation">]</span>$ <span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";print substr(info,4,10);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[wangsl@centos5 ~]$ awk 'BEGIN{info="this is a test2010test!";print substr(info,4,10);}'
|
||||
s is a tes
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>wangsl@centos5 ~<span class="token punctuation">]</span>$ <span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test2010test!";print substr(info,4,10);}'</span>
|
||||
s is a tes
|
||||
</code></pre>
|
||||
<p>从第 4个 字符开始,截取10个长度字符串</p>
|
||||
<p><strong>字符串分割(split使用)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}'
|
||||
4
|
||||
4 test
|
||||
1 this
|
||||
2 is
|
||||
3 a
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{info="this is a test";split(info,tA," ");print length(tA);for(k in tA){print k,tA[k];}}'</span>
|
||||
<span class="token number">4</span>
|
||||
<span class="token number">4</span> <span class="token builtin class-name">test</span>
|
||||
<span class="token number">1</span> this
|
||||
|
|
@ -849,7 +1147,9 @@ s is a tes
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{n1=124.113;n2=-1.224;n3=1.2345; printf("%.2f,%.2u,%.2g,%X,%on",n1,n2,n3,n1,n1);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{n1=124.113;n2=-1.224;n3=1.2345; printf("%.2f,%.2u,%.2g,%X,%on",n1,n2,n3,n1,n1);}'
|
||||
124.11,18446744073709551615,1.2,7C,174
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{n1=124.113;n2=-1.224;n3=1.2345; printf("%.2f,%.2u,%.2g,%X,%on",n1,n2,n3,n1,n1);}'</span>
|
||||
<span class="token number">124.11</span>,18446744073709551615,1.2,7C,174
|
||||
</code></pre>
|
||||
<h3 id="一般函数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#一般函数"><span class="octicon octicon-link"></span></a>一般函数</h3>
|
||||
|
|
@ -884,24 +1184,40 @@ s is a tes
|
|||
</tbody>
|
||||
</table>
|
||||
<p><strong>打开外部文件(close用法)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{while("cat /etc/passwd"|getline){print $0;};close("/etc/passwd");}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{while("cat /etc/passwd"|getline){print $0;};close("/etc/passwd");}'
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
bin:x:1:1:bin:/bin:/sbin/nologin
|
||||
daemon:x:2:2:daemon:/sbin:/sbin/nologin
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{while("cat /etc/passwd"|getline){print $0;};close("/etc/passwd");}'</span>
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
bin:x:1:1:bin:/bin:/sbin/nologin
|
||||
daemon:x:2:2:daemon:/sbin:/sbin/nologin
|
||||
</code></pre>
|
||||
<p><strong>逐行读取外部文件(getline使用方法)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{while(getline < "/etc/passwd"){print $0;};close("/etc/passwd");}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{while(getline < "/etc/passwd"){print $0;};close("/etc/passwd");}'
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
bin:x:1:1:bin:/bin:/sbin/nologin
|
||||
daemon:x:2:2:daemon:/sbin:/sbin/nologin
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{while(getline < "/etc/passwd"){print $0;};close("/etc/passwd");}'</span>
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
bin:x:1:1:bin:/bin:/sbin/nologin
|
||||
daemon:x:2:2:daemon:/sbin:/sbin/nologin
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{print "Enter your name:";getline name;print name;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{print "Enter your name:";getline name;print name;}'
|
||||
Enter your name:
|
||||
chengmo
|
||||
chengmo
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{print "Enter your name:";getline name;print name;}'</span>
|
||||
Enter your name:
|
||||
chengmo
|
||||
chengmo
|
||||
</code></pre>
|
||||
<p><strong>调用外部应用程序(system使用方法)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{b=system("ls -al");print b;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{b=system("ls -al");print b;}'
|
||||
total 42092
|
||||
drwxr-xr-x 14 chengmo chengmo 4096 09-30 17:47 .
|
||||
drwxr-xr-x 95 root root 4096 10-08 14:01 ..
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{b=system("ls -al");print b;}'</span>
|
||||
total <span class="token number">42092</span>
|
||||
drwxr-xr-x <span class="token number">14</span> chengmo chengmo <span class="token number">4096</span> 09-30 <span class="token number">17</span>:47 <span class="token builtin class-name">.</span>
|
||||
drwxr-xr-x <span class="token number">95</span> root root <span class="token number">4096</span> <span class="token number">10</span>-08 <span class="token number">14</span>:01 <span class="token punctuation">..</span>
|
||||
|
|
@ -935,14 +1251,20 @@ drwxr-xr-x <span class="token number">95</span> root root <span class="t
|
|||
</tbody>
|
||||
</table>
|
||||
<p><strong>建指定时间(mktime使用)</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp=mktime("2001 01 01 12 12 12");print strftime("%c",tstamp);}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{tstamp=mktime("2001 01 01 12 12 12");print strftime("%c",tstamp);}'
|
||||
2001年01月01日 星期一 12时12分12秒
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp=mktime("2001 01 01 12 12 12");print strftime("%c",tstamp);}'</span>
|
||||
<span class="token number">2001</span>年01月01日 星期一 <span class="token number">12</span>时12分12秒
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=mktime("2001 02 01 0 0 0");print tstamp2-tstamp1;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=mktime("2001 02 01 0 0 0");print tstamp2-tstamp1;}'
|
||||
2634468
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=mktime("2001 02 01 0 0 0");print tstamp2-tstamp1;}'</span>
|
||||
<span class="token number">2634468</span>
|
||||
</code></pre>
|
||||
<p>求2个时间段中间时间差,介绍了strftime使用方法</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=systime();print tstamp2-tstamp1;}'</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="awk 'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=systime();print tstamp2-tstamp1;}'
|
||||
308201392
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">awk</span> <span class="token string">'BEGIN{tstamp1=mktime("2001 01 01 12 12 12");tstamp2=systime();print tstamp2-tstamp1;}'</span>
|
||||
<span class="token number">308201392</span>
|
||||
</code></pre>
|
||||
<p><strong>strftime日期和时间格式说明符</strong></p>
|
||||
|
|
@ -1073,7 +1395,7 @@ drwxr-xr-x <span class="token number">95</span> root root <span class="t
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198669"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198669"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219986"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219986"></script>
|
||||
</body>
|
||||
</html>
|
||||
37
c/axel.html
37
c/axel.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,axel,多线程下载工具">
|
||||
<title>axel 命令,Linux axel 命令详解:多线程下载工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198685">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357219998">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -60,21 +60,39 @@
|
|||
<p>CentOS安装Axel:</p>
|
||||
<p>目前yum源上没有Axel,我们可以到 <a href="http://pkgs.repoforge.org/axel/">http://pkgs.repoforge.org/axel/</a> 下载rpm包安装。</p>
|
||||
<p>32位CentOS执行下面命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">wget</span> -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.i386.rpm
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.i386.rpm
|
||||
rpm -ivh axel-2.4-1.el5.rf.i386.rpm
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">wget</span> -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.i386.rpm
|
||||
<span class="token function">rpm</span> -ivh axel-2.4-1.el5.rf.i386.rpm
|
||||
</code></pre>
|
||||
<p>64位CentOS执行下面命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">wget</span> -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="wget -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm
|
||||
rpm -ivh axel-2.4-1.el5.rf.x86_64.rpm
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">wget</span> -c http://pkgs.repoforge.org/axel/axel-2.4-1.el5.rf.x86_64.rpm
|
||||
<span class="token function">rpm</span> -ivh axel-2.4-1.el5.rf.x86_64.rpm
|
||||
</code></pre>
|
||||
<p>Debian/Ubuntu安装Axel:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> axel
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="apt-get install axel
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">apt-get</span> <span class="token function">install</span> axel
|
||||
</code></pre>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">axel <span class="token punctuation">[</span>options<span class="token punctuation">]</span> url1 <span class="token punctuation">[</span>url2<span class="token punctuation">]</span> <span class="token punctuation">[</span>url<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="axel [options] url1 [url2] [url...]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">axel <span class="token punctuation">[</span>options<span class="token punctuation">]</span> url1 <span class="token punctuation">[</span>url2<span class="token punctuation">]</span> <span class="token punctuation">[</span>url<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--max-speed<span class="token operator">=</span>x , -s x <span class="token comment"># 最高速度x</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--max-speed=x , -s x # 最高速度x
|
||||
--num-connections=x , -n x # 连接数x
|
||||
--output=f , -o f # 下载为本地文件f
|
||||
--search[=x] , -S [x] # 搜索镜像
|
||||
--header=x , -H x # 添加头文件字符串x(指定 HTTP header)
|
||||
--user-agent=x , -U x # 设置用户代理(指定 HTTP user agent)
|
||||
--no-proxy , -N # 不使用代理服务器
|
||||
--quiet , -q # 静默模式
|
||||
--verbose ,-v # 更多状态信息
|
||||
--alternate , -a # Alternate progress indicator
|
||||
--help ,-h # 帮助
|
||||
--version ,-V # 版本信息
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--max-speed<span class="token operator">=</span>x , -s x <span class="token comment"># 最高速度x</span>
|
||||
--num-connections<span class="token operator">=</span>x , -n x <span class="token comment"># 连接数x</span>
|
||||
--output<span class="token operator">=</span>f , -o f <span class="token comment"># 下载为本地文件f</span>
|
||||
--search<span class="token punctuation">[</span><span class="token operator">=</span>x<span class="token punctuation">]</span> , -S <span class="token punctuation">[</span>x<span class="token punctuation">]</span> <span class="token comment"># 搜索镜像</span>
|
||||
|
|
@ -89,7 +107,8 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>如下载lnmp安装包指定10个线程,存到 <code>/tmp/</code>:</p>
|
||||
<pre class="language-shell"><code class="language-shell">axel -n <span class="token number">10</span> -o /tmp/ http://www.jsdig.com/lnmp.tar.gz
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="axel -n 10 -o /tmp/ http://www.jsdig.com/lnmp.tar.gz
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">axel -n <span class="token number">10</span> -o /tmp/ http://www.jsdig.com/lnmp.tar.gz
|
||||
</code></pre>
|
||||
<p>如果下载过程中下载中断可以再执行下载命令即可恢复上次的下载进度。</p>
|
||||
</div>
|
||||
|
|
@ -117,7 +136,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198686"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198686"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357219999"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357219999"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,badblocks,查找磁盘中损坏的区块">
|
||||
<title>badblocks 命令,Linux badblocks 命令详解:查找磁盘中损坏的区块 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198709">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220014">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,16 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>badblock命令</strong> 用于查找磁盘中损坏的区块。 硬盘是一个损耗设备,当使用一段时间后可能会出现坏道等物理故障。电脑硬盘出现坏道后,如果不及时更换或进行技术处理,坏道就会越来越多,并会造成频繁死机和数据丢失。最好的处理方式是更换磁盘,但在临时的情况下,应及时屏蔽坏道部分的扇区,不要触动它们。badblocks就是一个很好的检查坏道位置的工具。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">badblock<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="badblock(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">badblock<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b<span class="token operator"><</span>区块大小<span class="token operator">></span>:指定磁盘的区块大小,单位为字节;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b<区块大小>:指定磁盘的区块大小,单位为字节;
|
||||
-o<输出文件>:将检查的结果写入指定的输出文件;
|
||||
-s:在检查时显示进度;
|
||||
-v:执行时显示详细的信息;
|
||||
-w:在检查时,执行写入测试。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b<span class="token operator"><</span>区块大小<span class="token operator">></span>:指定磁盘的区块大小,单位为字节;
|
||||
-o<span class="token operator"><</span>输出文件<span class="token operator">></span>:将检查的结果写入指定的输出文件;
|
||||
-s:在检查时显示进度;
|
||||
-v:执行时显示详细的信息;
|
||||
|
|
@ -74,10 +80,20 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>badblocks以 4096 的一个block,每一个block检查16次,将结果输出到“hda-badblocks-list”文件里。</p>
|
||||
<pre class="language-shell"><code class="language-shell">badblocks -b <span class="token number">4096</span> -c <span class="token number">16</span> /dev/hda1 -o hda-badblocks-list
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="badblocks -b 4096 -c 16 /dev/hda1 -o hda-badblocks-list
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">badblocks -b <span class="token number">4096</span> -c <span class="token number">16</span> /dev/hda1 -o hda-badblocks-list
|
||||
</code></pre>
|
||||
<p>hda-badblocks-list是个文本文件,内容如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> hda-badblocks-list
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat hda-badblocks-list
|
||||
51249
|
||||
51250
|
||||
51251
|
||||
51253
|
||||
51254
|
||||
……
|
||||
61245
|
||||
……
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> hda-badblocks-list
|
||||
<span class="token number">51249</span>
|
||||
<span class="token number">51250</span>
|
||||
<span class="token number">51251</span>
|
||||
|
|
@ -88,17 +104,20 @@
|
|||
……
|
||||
</code></pre>
|
||||
<p>可以针对可疑的区块多做几次操作。下面,badblocks以4096字节为一个“block”,每一个“block”检查1次, 将结果输出到“hda-badblocks-list.1”文件中,由第51000 block开始,到63000 block结束。</p>
|
||||
<pre class="language-shell"><code class="language-shell">badblocks -b <span class="token number">4096</span> -c <span class="token number">1</span> /dev/hda1 -o hda-badblocks-list.1 <span class="token number">63000</span> <span class="token number">51000</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="badblocks -b 4096 -c 1 /dev/hda1 -o hda-badblocks-list.1 63000 51000
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">badblocks -b <span class="token number">4096</span> -c <span class="token number">1</span> /dev/hda1 -o hda-badblocks-list.1 <span class="token number">63000</span> <span class="token number">51000</span>
|
||||
</code></pre>
|
||||
<p>这次花费的时间比较短,硬盘在指定的情况下在很短的时间就产生“嘎嘎嘎嘎”的响声。由于检查条件的不同,其输出的结果也不完全是相同的。重复几次同样的操作,因条件多少都有些不同,所以结果也有所不同。进行多次操作后,直到产生最后的hda-badblock-list.final文件。</p>
|
||||
<h3 id="其他"><a class="anchor" aria-hidden="true" tabindex="-1" href="#其他"><span class="octicon octicon-link"></span></a>其他</h3>
|
||||
<p><strong>1、fsck使用badblocks的信息</strong></p>
|
||||
<p>badblocks只会在日志文件中标记出坏道的信息,但若希望在检测磁盘时也能跳过这些坏块不检测,可以使用fsck的-l参数:</p>
|
||||
<pre><code>fsck.ext3 -l /tmp/hda-badblock-list.final /dev/hda1
|
||||
<pre><div onclick="copied(this)" data-code="fsck.ext3 -l /tmp/hda-badblock-list.final /dev/hda1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code>fsck.ext3 -l /tmp/hda-badblock-list.final /dev/hda1
|
||||
</code></pre>
|
||||
<p><strong>2、在创建文件系统前检测坏道</strong></p>
|
||||
<p>badblocks可以随e2fsck和mke2fs的-c删除一起运行(对ext3文件系统也一样),在创建文件系统前就先检测坏道信息:</p>
|
||||
<pre class="language-shell"><code class="language-shell">mkfs.ext3 -c /dev/hda1
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="mkfs.ext3 -c /dev/hda1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">mkfs.ext3 -c /dev/hda1
|
||||
</code></pre>
|
||||
<p>代码表示使用-c在创建文件系统前检查坏道的硬盘。</p>
|
||||
<p>这个操作已经很清楚地告知我们可以采用<code>mkfs.ext3 -c</code>选项用<code>read-only</code>方式检查硬盘。这个命令会在格式化硬盘时检查硬盘,并标出错误的硬盘“block”。用这个方法格式化硬盘,需要有相当大的耐心,因为命令运行后,会一个个用读的方式检查硬盘。</p>
|
||||
|
|
@ -127,7 +146,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198710"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198710"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220015"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220015"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,base64,base64 编码/解码文件或标准输入输出">
|
||||
<title>base64 命令,Linux base64 命令详解:base64 编码/解码文件或标准输入输出 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198718">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220027">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h3 id="描述"><a class="anchor" aria-hidden="true" tabindex="-1" href="#描述"><span class="octicon octicon-link"></span></a>描述</h3>
|
||||
<p>base64将<code>文件</code>或<code>标准输入</code>编码或解码为标准输出;</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">base64 <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>FILE<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="base64 [OPTION]... [FILE]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">base64 <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>FILE<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-d, --decode <span class="token comment"># 解码</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-d, --decode # 解码
|
||||
-i, --ignore-garbage # 解码时,忽略非字母字符
|
||||
-w, --wrap=COLS # 在指定的字符数后自动换行(默认为76), 0 为禁用自动换行
|
||||
|
||||
--help # 显示此帮助说明并退出
|
||||
--version # 输出版本信息并退出
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-d, --decode <span class="token comment"># 解码</span>
|
||||
-i, --ignore-garbage <span class="token comment"># 解码时,忽略非字母字符</span>
|
||||
-w, --wrap<span class="token operator">=</span>COLS <span class="token comment"># 在指定的字符数后自动换行(默认为76), 0 为禁用自动换行</span>
|
||||
|
||||
|
|
@ -69,16 +76,20 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>编码字符串</p>
|
||||
<pre class="language-bash"><code class="language-bash"><span class="token builtin class-name">printf</span> foo<span class="token operator">|</span>base64
|
||||
<pre class="language-bash"><div onclick="copied(this)" data-code="printf foo|base64
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-bash"><span class="token builtin class-name">printf</span> foo<span class="token operator">|</span>base64
|
||||
</code></pre>
|
||||
<p>编码文件</p>
|
||||
<pre class="language-bash"><code class="language-bash">base64 <span class="token function">file</span>
|
||||
<pre class="language-bash"><div onclick="copied(this)" data-code="base64 file
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-bash">base64 <span class="token function">file</span>
|
||||
</code></pre>
|
||||
<p>解码</p>
|
||||
<pre class="language-bash"><code class="language-bash"><span class="token builtin class-name">printf</span> Zm9v<span class="token operator">|</span>base64 -d
|
||||
<pre class="language-bash"><div onclick="copied(this)" data-code="printf Zm9v|base64 -d
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-bash"><span class="token builtin class-name">printf</span> Zm9v<span class="token operator">|</span>base64 -d
|
||||
</code></pre>
|
||||
<p>解码文件</p>
|
||||
<pre class="language-bash"><code class="language-bash">base64 -d <span class="token function">file</span>
|
||||
<pre class="language-bash"><div onclick="copied(this)" data-code="base64 -d file
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-bash">base64 -d <span class="token function">file</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -105,7 +116,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198719"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198719"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220028"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220028"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,basename,打印目录或者文件的基本名称">
|
||||
<title>basename 命令,Linux basename 命令详解:打印目录或者文件的基本名称 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198733">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220039">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,13 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>basename命令</strong> 用于打印目录或者文件的基本名称。basename和dirname命令通常用于shell脚本中的命令替换来指定和指定的输入文件名称有所差异的输出文件名称。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">basename<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="basename(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">basename<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--help:显示帮助;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--help:显示帮助;
|
||||
--version:显示版本号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--help:显示帮助;
|
||||
--version:显示版本号。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
|
|
@ -70,11 +73,13 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>1、要显示一个shell变量的基本名称,请输入:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">basename</span> <span class="token variable">$WORKFILE</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="basename $WORKFILE
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">basename</span> <span class="token variable">$WORKFILE</span>
|
||||
</code></pre>
|
||||
<p>此命令显示指定给shell变量WORKFILE的值的基本名称。如果WORKFILE变量的值是<code>/home/jim/program.c</code>文件,则此命令显示program.c。</p>
|
||||
<p>要构造一个和另一个文件名称相同(除了后缀)的文件名称,请输入:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable">OFILE</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">basename</span> $1 .c<span class="token variable">`</span></span>.o
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="OFILE=`basename $1 .c`.o
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable">OFILE</span><span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token function">basename</span> $1 .c<span class="token variable">`</span></span>.o
|
||||
</code></pre>
|
||||
<p>此命令指定给 OFILE 文件第一个位置上的参数($1)的值,但它的 .c 后缀更改至 .o。如果 $1 是 /home/jim/program.c 文件,则 OFILE 成为 program.o。因为 program.o 仅是一个基本文件名称,它标识在当前目录中的文件。</p>
|
||||
</div>
|
||||
|
|
@ -102,7 +107,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198734"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198734"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220040"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220040"></script>
|
||||
</body>
|
||||
</html>
|
||||
20
c/batch.html
20
c/batch.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,batch,在系统不繁忙的时候执行定时任务">
|
||||
<title>batch 命令,Linux batch 命令详解:在系统不繁忙的时候执行定时任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198743">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220047">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,17 +57,25 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>batch命令</strong> 用于在指定时间,当系统不繁忙时执行任务,用法与at相似。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">batch<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="batch(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">batch<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-f:指定包含具体指令的任务文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f:指定包含具体指令的任务文件;
|
||||
-q:指定新任务的队列名称;
|
||||
-m:任务执行完后向用户发送E-mail。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f:指定包含具体指令的任务文件;
|
||||
-q:指定新任务的队列名称;
|
||||
-m:任务执行完后向用户发送E-mail。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>日期时间:指定任务执行的日期时间。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">batch
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="batch
|
||||
at> echo 1234
|
||||
at> <EOT>
|
||||
job 5 at Sun Apr 28 08:49:00 2013
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">batch
|
||||
at<span class="token operator">></span> <span class="token builtin class-name">echo</span> <span class="token number">1234</span>
|
||||
at<span class="token operator">></span> <span class="token operator"><</span>EOT<span class="token operator">></span>
|
||||
job <span class="token number">5</span> at Sun Apr <span class="token number">28</span> 08:49:00 <span class="token number">2013</span>
|
||||
|
|
@ -97,7 +105,7 @@ job <span class="token number">5</span> at Sun Apr <span class="token number">28
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198744"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198744"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220047"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220047"></script>
|
||||
</body>
|
||||
</html>
|
||||
43
c/bc.html
43
c/bc.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bc,算术操作精密运算工具">
|
||||
<title>bc 命令,Linux bc 命令详解:算术操作精密运算工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198755">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220060">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bc命令</strong> 是一种支持任意精度的交互执行的计算器语言。bash内置了对整数四则运算的支持,但是并不支持浮点运算,而bc命令可以很方便的进行浮点运算,当然整数运算也不再话下。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bc<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bc(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bc<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-i:强制进入交互式模式;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-i:强制进入交互式模式;
|
||||
-l:定义使用的标准数学库;
|
||||
-w:对POSIX bc的扩展给出警告信息;
|
||||
-q:不打印正常的GNU bc环境信息;
|
||||
-v:显示指令版本信息;
|
||||
-h:显示指令的帮助信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-i:强制进入交互式模式;
|
||||
-l:定义使用的标准数学库;
|
||||
-w:对POSIX bc的扩展给出警告信息;
|
||||
-q:不打印正常的GNU bc环境信息;
|
||||
|
|
@ -71,31 +78,47 @@
|
|||
<p>文件:指定包含计算任务的文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>算术操作高级运算bc命令它可以执行浮点运算和一些高级函数:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"1.212*3"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo "1.212*3" | bc
|
||||
3.636
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"1.212*3"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<span class="token number">3.636</span>
|
||||
|
||||
</code></pre>
|
||||
<p>设定小数精度(数值范围)</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"scale=2;3/8"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo "scale=2;3/8" | bc
|
||||
0.37
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"scale=2;3/8"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<span class="token number">0.37</span>
|
||||
|
||||
</code></pre>
|
||||
<p>参数<code>scale=2</code>是将bc输出结果的小数位设置为2位。</p>
|
||||
<p>进制转换</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token shebang important">#!/bin/bash</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="#!/bin/bash
|
||||
abc=192
|
||||
echo "obase=2;$abc" | bc
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token shebang important">#!/bin/bash</span>
|
||||
<span class="token assign-left variable">abc</span><span class="token operator">=</span><span class="token number">192</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"obase=2;<span class="token variable">$abc</span>"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
|
||||
</code></pre>
|
||||
<p>执行结果为:11000000,这是用bc将十进制转换成二进制。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token shebang important">#!/bin/bash</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="#!/bin/bash
|
||||
abc=11000000
|
||||
echo "obase=10;ibase=2;$abc" | bc
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token shebang important">#!/bin/bash</span>
|
||||
<span class="token assign-left variable">abc</span><span class="token operator">=</span><span class="token number">11000000</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"obase=10;ibase=2;<span class="token variable">$abc</span>"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
|
||||
</code></pre>
|
||||
<p>执行结果为:192,这是用bc将二进制转换为十进制。</p>
|
||||
<p>计算平方和平方根:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"10^10"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="echo "10^10" | bc
|
||||
echo "sqrt(100)" | bc
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">echo</span> <span class="token string">"10^10"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"sqrt(100)"</span> <span class="token operator">|</span> <span class="token function">bc</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -123,7 +146,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198755"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198755"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220061"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220061"></script>
|
||||
</body>
|
||||
</html>
|
||||
21
c/bg.html
21
c/bg.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bg,将前台终端作业移动到后台运行">
|
||||
<title>bg 命令,Linux bg 命令详解:将前台终端作业移动到后台运行 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198766">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220072">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="bg"><a class="anchor" aria-hidden="true" tabindex="-1" href="#bg"><span class="octicon octicon-link"></span></a>bg</h1>
|
||||
<p>将前台终端作业移动到后台运行</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bg</span> <span class="token punctuation">[</span>job_spec <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bg [job_spec ...]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bg</span> <span class="token punctuation">[</span>job_spec <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -71,7 +72,17 @@
|
|||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回成功除非未开启作业控制或发生了错误。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 运行sleep命令,然后按下ctrl+z。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 运行sleep命令,然后按下ctrl+z。
|
||||
sleep 60
|
||||
^Z
|
||||
[1]+ Stopped sleep 60
|
||||
|
||||
# 使用bg命令使得作业在后台运行。
|
||||
bg %1
|
||||
|
||||
# 返回信息:
|
||||
[1]+ sleep 60 &
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 运行sleep命令,然后按下ctrl+z。</span>
|
||||
<span class="token function">sleep</span> <span class="token number">60</span>
|
||||
^Z
|
||||
<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span>+ Stopped <span class="token function">sleep</span> <span class="token number">60</span>
|
||||
|
|
@ -113,7 +124,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198767"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198767"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220073"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220073"></script>
|
||||
</body>
|
||||
</html>
|
||||
42
c/bind.html
42
c/bind.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bind,显示或设置键盘按键与其相关的功能">
|
||||
<title>bind 命令,Linux bind 命令详解:显示或设置键盘按键与其相关的功能 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198779">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220082">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bind命令</strong> 用于显示和设置命令行的键盘序列绑定功能。通过这一命令,可以提高命令行中操作效率。您可以利用bind命令了解有哪些按键组合与其功能,也可以自行指定要用哪些按键组合。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bind<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bind(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bind<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-d:显示按键配置的内容;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-d:显示按键配置的内容;
|
||||
-f<按键配置文件>:载入指定的按键配置文件;
|
||||
-l:列出所有的功能;
|
||||
-m<按键配置>:指定按键配置;
|
||||
-q<功能>:显示指定功能的按键;
|
||||
-v:列出目前的按键配置与其功能。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-d:显示按键配置的内容;
|
||||
-f<span class="token operator"><</span>按键配置文件<span class="token operator">></span>:载入指定的按键配置文件;
|
||||
-l:列出所有的功能;
|
||||
-m<span class="token operator"><</span>按键配置<span class="token operator">></span>:指定按键配置;
|
||||
|
|
@ -68,10 +75,31 @@
|
|||
-v:列出目前的按键配置与其功能。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">bind</span> -x <span class="token string">'"\C-l":ls -l'</span> <span class="token comment">#直接按 CTRL+L 就列出目录</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bind -x '"\C-l":ls -l' #直接按 CTRL+L 就列出目录
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">bind</span> -x <span class="token string">'"\C-l":ls -l'</span> <span class="token comment">#直接按 CTRL+L 就列出目录</span>
|
||||
</code></pre>
|
||||
<p>其中keyseq可以使用<code>showkey -a</code>命令来获取:</p>
|
||||
<pre class="language-shell"><code class="language-shell">showkey -a
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="showkey -a
|
||||
|
||||
Press any keys - Ctrl-D will terminate this program
|
||||
|
||||
^[[A 27 0033 0x1b 上
|
||||
91 0133 0x5b
|
||||
65 0101 0x41
|
||||
^[[B 27 0033 0x1b 下
|
||||
91 0133 0x5b
|
||||
66 0102 0x42
|
||||
^[[D 27 0033 0x1b 左
|
||||
91 0133 0x5b
|
||||
68 0104 0x44
|
||||
^[[C 27 0033 0x1b 右
|
||||
91 0133 0x5b
|
||||
67 0103 0x43
|
||||
32 0040 0x20
|
||||
^M 13 0015 0x0d 字母M
|
||||
^C 3 0003 0x03 Ctrl-C
|
||||
^D 4 0004 0x04 Ctrl-D 退出
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">showkey -a
|
||||
|
||||
Press any keys - Ctrl-D will terminate this program
|
||||
|
||||
|
|
@ -117,7 +145,7 @@ Press any keys - Ctrl-D will terminate this program
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198780"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198780"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220083"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220083"></script>
|
||||
</body>
|
||||
</html>
|
||||
59
c/blkid.html
59
c/blkid.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,blkid,查看块设备的文件系统类型、LABEL、UUID等信息">
|
||||
<title>blkid 命令,Linux blkid 命令详解:查看块设备的文件系统类型、LABEL、UUID等信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198800">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220104">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,13 +57,38 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p>在Linux下可以使用 <strong>blkid命令</strong> 对查询设备上所采用文件系统类型进行查询。blkid主要用来对系统的块设备(包括交换分区)所使用的文件系统类型、LABEL、UUID等信息进行查询。要使用这个命令必须安装e2fsprogs软件包。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">blkid -L <span class="token operator">|</span> -U
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="blkid -L | -U
|
||||
blkid [-c ] [-ghlLv] [-o] [-s ][-t ] -[w ] [ ...]
|
||||
blkid -p [-s ] [-O ] [-S ][-o] ...
|
||||
blkid -i [-s ] [-o] ...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">blkid -L <span class="token operator">|</span> -U
|
||||
blkid <span class="token punctuation">[</span>-c <span class="token punctuation">]</span> <span class="token punctuation">[</span>-ghlLv<span class="token punctuation">]</span> <span class="token punctuation">[</span>-o<span class="token punctuation">]</span> <span class="token punctuation">[</span>-s <span class="token punctuation">]</span><span class="token punctuation">[</span>-t <span class="token punctuation">]</span> -<span class="token punctuation">[</span>w <span class="token punctuation">]</span> <span class="token punctuation">[</span> <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
blkid -p <span class="token punctuation">[</span>-s <span class="token punctuation">]</span> <span class="token punctuation">[</span>-O <span class="token punctuation">]</span> <span class="token punctuation">[</span>-S <span class="token punctuation">]</span><span class="token punctuation">[</span>-o<span class="token punctuation">]</span> <span class="token punctuation">..</span>.
|
||||
blkid -i <span class="token punctuation">[</span>-s <span class="token punctuation">]</span> <span class="token punctuation">[</span>-o<span class="token punctuation">]</span> <span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-c <span class="token operator"><</span>file<span class="token operator">></span> <span class="token comment"># 指定cache文件(default: /etc/blkid.tab, /dev/null = none)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c <file> # 指定cache文件(default: /etc/blkid.tab, /dev/null = none)
|
||||
-d # don't encode non-printing characters
|
||||
-h # 显示帮助信息
|
||||
-g # garbage collect the blkid cache
|
||||
-o <format> # 指定输出格式
|
||||
-k # list all known filesystems/RAIDs and exit
|
||||
-s <tag> # 显示指定信息,默认显示所有信息
|
||||
-t <token> # find device with a specific token (NAME=value pair)
|
||||
-l # look up only first device with token specified by -t
|
||||
-L <label> # convert LABEL to device name
|
||||
-U <uuid> # convert UUID to device name
|
||||
-v # 显示版本信息
|
||||
-w <file> # write cache to different file (/dev/null = no write)
|
||||
<dev> # specify device(s) to probe (default: all devices)
|
||||
Low-level probing options:
|
||||
-p # low-level superblocks probing (bypass cache)
|
||||
-i # gather information about I/O limits
|
||||
-S <size> # overwrite device size
|
||||
-O <offset> # probe at the given offset
|
||||
-u <list> # filter by "usage" (e.g. -u filesystem,raid)
|
||||
-n <list> # filter by filesystem type (e.g. -n vfat,ext3)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c <span class="token operator"><</span>file<span class="token operator">></span> <span class="token comment"># 指定cache文件(default: /etc/blkid.tab, /dev/null = none)</span>
|
||||
-d <span class="token comment"># don't encode non-printing characters</span>
|
||||
-h <span class="token comment"># 显示帮助信息</span>
|
||||
-g <span class="token comment"># garbage collect the blkid cache</span>
|
||||
|
|
@ -87,28 +112,36 @@ Low-level probing options:
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>1、列出当前系统中所有已挂载文件系统的类型:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid
|
||||
</code></pre>
|
||||
<p>2、显示指定设备 UUID:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -s UUID /dev/sda5
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -s UUID /dev/sda5
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -s UUID /dev/sda5
|
||||
</code></pre>
|
||||
<p>3、显示所有设备 UUID:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -s UUID
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -s UUID
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -s UUID
|
||||
</code></pre>
|
||||
<p>4、显示指定设备 LABEL:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -s LABEL /dev/sda5
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -s LABEL /dev/sda5
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -s LABEL /dev/sda5
|
||||
</code></pre>
|
||||
<p>5、显示所有设备 LABEL:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -s LABEL
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -s LABEL
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -s LABEL
|
||||
</code></pre>
|
||||
<p>6、显示所有设备文件系统:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -s TYPE
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -s TYPE
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -s TYPE
|
||||
</code></pre>
|
||||
<p>7、显示所有设备:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -o device
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -o device
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -o device
|
||||
</code></pre>
|
||||
<p>8、以列表方式查看详细信息:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">sudo</span> blkid -o list
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="sudo blkid -o list
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">sudo</span> blkid -o list
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -135,7 +168,7 @@ Low-level probing options:
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198801"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198801"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220104"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220104"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,blockdev,从命令行调用区块设备控制程序">
|
||||
<title>blockdev 命令,Linux blockdev 命令详解:从命令行调用区块设备控制程序 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198808">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220112">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,20 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>blockdev命令</strong> 在命令调用“ioxtls”函数,以实现对设备的控制。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">blockdev<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="blockdev(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">blockdev<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<p>选项</p>
|
||||
<pre class="language-shell"><code class="language-shell">-V:打印版本号并退出;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-V:打印版本号并退出;
|
||||
-q:安静模式;
|
||||
-v:详细信息模式;
|
||||
--setro:只读;
|
||||
--setrw:只写;
|
||||
--getro:打印只读状态,“1”表示只读,“0”表示非只读;
|
||||
--getss:打印扇区大小。通常为521;
|
||||
--flushbufs:刷新缓冲区;
|
||||
--rereadpt:重新读取分区表。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-V:打印版本号并退出;
|
||||
-q:安静模式;
|
||||
-v:详细信息模式;
|
||||
--setro:只读;
|
||||
|
|
@ -74,13 +84,16 @@
|
|||
<p>设备文件名:指定要操作的磁盘的设备文件名。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>设置设备为只读:</p>
|
||||
<pre class="language-shell"><code class="language-shell">blockdev --setro /dev/hda4
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="blockdev --setro /dev/hda4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">blockdev --setro /dev/hda4
|
||||
</code></pre>
|
||||
<p>读取设备是否为只读:</p>
|
||||
<pre class="language-shell"><code class="language-shell">blockdev --getro /dev/hda4
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="blockdev --getro /dev/hda4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">blockdev --getro /dev/hda4
|
||||
</code></pre>
|
||||
<p>设置设别为可读写:</p>
|
||||
<pre class="language-shell"><code class="language-shell">blockdev --setrw /dev/hda4
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="blockdev --setrw /dev/hda4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">blockdev --setrw /dev/hda4
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -107,7 +120,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198809"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198809"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220113"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220113"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bmodinfo,显示给定模块的详细信息">
|
||||
<title>bmodinfo 命令,Linux bmodinfo 命令详解:显示给定模块的详细信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198815">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220120">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bmodinfo命令</strong> 用于显示给定模块的详细信息。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bmodinfo<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bmodinfo(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bmodinfo<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a:显示模块作者;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a:显示模块作者;
|
||||
-d:显示模块的描述信息;
|
||||
-l:显示模块的许可信息;
|
||||
-p:显示模块的参数信息;
|
||||
-n:显示模块对应的文字信息;
|
||||
-0:用ASCII码的0字符分割字段值,而不使用新行。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a:显示模块作者;
|
||||
-d:显示模块的描述信息;
|
||||
-l:显示模块的许可信息;
|
||||
-p:显示模块的参数信息;
|
||||
|
|
@ -71,7 +78,18 @@
|
|||
<p>模块名:要显示详细信息的模块名称。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>显示sg模块的信息:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># modinfo sg</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# modinfo sg
|
||||
filename: /lib/modules/2.6.9-42.ELsmp/kernel/drivers/scsi/sg.ko
|
||||
author: Douglas Gilbert
|
||||
description: SCSI generic (sg) driver
|
||||
license: GPL
|
||||
version: 3.5.31 B0B0CB1BB59F0669A1F0D6B
|
||||
parm: def_reserved_size:size of buffer reserved for each fd
|
||||
parm: allow_dio:allow direct I/O (default: 0 (disallow))
|
||||
alias: char-major-21-*
|
||||
vermagic: 2.6.9-42.ELsmp SMP 686 REGPARM 4KSTACKS gcc-3.4
|
||||
depends: scsi_mod
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># modinfo sg</span>
|
||||
filename: /lib/modules/2.6.9-42.ELsmp/kernel/drivers/scsi/sg.ko
|
||||
author: Douglas Gilbert
|
||||
description: SCSI generic <span class="token punctuation">(</span>sg<span class="token punctuation">)</span> driver
|
||||
|
|
@ -108,7 +126,7 @@ depends: scsi_mod
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198816"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198816"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220120"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220120"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
c/break.html
40
c/break.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,break,结束for,while或until循环。">
|
||||
<title>break 命令,Linux break 命令详解:结束for,while或until循环。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198834">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220136">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="break"><a class="anchor" aria-hidden="true" tabindex="-1" href="#break"><span class="octicon octicon-link"></span></a>break</h1>
|
||||
<p>结束for,while或until循环。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">break</span> <span class="token punctuation">[</span>n<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="break [n]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">break</span> <span class="token punctuation">[</span>n<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -66,7 +67,22 @@
|
|||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回成功除非n小于1。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># break的可选参数n缺省值为1。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# break的可选参数n缺省值为1。
|
||||
# 从外层for循环继续执行。
|
||||
for((i=3;i>0;i--)); do
|
||||
for((j=3;j>0;j--)); do
|
||||
if((j==2)); then
|
||||
# 换成break 1时结果一样
|
||||
break
|
||||
fi
|
||||
printf "%s %s\n" ${i} ${j}
|
||||
done
|
||||
done
|
||||
# 输出结果
|
||||
3 3
|
||||
2 3
|
||||
1 3
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># break的可选参数n缺省值为1。</span>
|
||||
<span class="token comment"># 从外层for循环继续执行。</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>i<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>i<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>j<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>j<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>j<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
|
|
@ -82,7 +98,19 @@
|
|||
<span class="token number">2</span> <span class="token number">3</span>
|
||||
<span class="token number">1</span> <span class="token number">3</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 当n为2时:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 当n为2时:
|
||||
# 退出两层循环,结束。
|
||||
for((i=3;i>0;i--)); do
|
||||
for((j=3;j>0;j--)); do
|
||||
if((j==2)); then
|
||||
break 2
|
||||
fi
|
||||
printf "%s %s\n" ${i} ${j}
|
||||
done
|
||||
done
|
||||
# 输出结果
|
||||
3 3
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 当n为2时:</span>
|
||||
<span class="token comment"># 退出两层循环,结束。</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>i<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>i<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>j<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>j<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>j<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
|
|
@ -124,7 +152,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198834"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198834"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220137"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220137"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,builtin,执行bash内建命令。">
|
||||
<title>builtin 命令,Linux builtin 命令详解:执行bash内建命令。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198848">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220149">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="builtin"><a class="anchor" aria-hidden="true" tabindex="-1" href="#builtin"><span class="octicon octicon-link"></span></a>builtin</h1>
|
||||
<p>执行bash内建命令。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">builtin</span> <span class="token punctuation">[</span>shell-builtin <span class="token punctuation">[</span>arg <span class="token punctuation">..</span>.<span class="token punctuation">]</span><span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="builtin [shell-builtin [arg ...]]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">builtin</span> <span class="token punctuation">[</span>shell-builtin <span class="token punctuation">[</span>arg <span class="token punctuation">..</span>.<span class="token punctuation">]</span><span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -70,7 +71,22 @@
|
|||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<p>同名情况下的优先级顺序:</p>
|
||||
<p>builtin 内建命令 > 函数 > 内建命令 > 外部命令</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 关于外部命令优先级最高的情况请参考enable命令。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 关于外部命令优先级最高的情况请参考enable命令。
|
||||
# 此时内建命令优先使用
|
||||
echo "the Great Wall"
|
||||
# 调用内建命令type,返回命令的类型(builtin)
|
||||
type -t echo
|
||||
# 定义 echo 函数
|
||||
echo(){
|
||||
printf "123\n"
|
||||
}
|
||||
# 此时同名函数优先使用,显示(123)
|
||||
echo
|
||||
# 调用内建命令type,返回命令的类型(function)
|
||||
type -t echo
|
||||
# 此时内建命令优先使用
|
||||
builtin echo -e "backslash \\"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 关于外部命令优先级最高的情况请参考enable命令。</span>
|
||||
<span class="token comment"># 此时内建命令优先使用</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"the Great Wall"</span>
|
||||
<span class="token comment"># 调用内建命令type,返回命令的类型(builtin)</span>
|
||||
|
|
@ -86,7 +102,16 @@
|
|||
<span class="token comment"># 此时内建命令优先使用</span>
|
||||
<span class="token builtin class-name">builtin</span> <span class="token builtin class-name">echo</span> -e <span class="token string">"backslash <span class="token entity" title="\\">\\</span>"</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 执行shell内部指令,输出当前系统下的命令别名</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 执行shell内部指令,输出当前系统下的命令别名
|
||||
builtin alias
|
||||
alias cp='cp -i'
|
||||
alias l.='ls -d .* --color=tty'
|
||||
alias ll='ls -l --color=tty'
|
||||
alias ls='ls --color=tty'
|
||||
alias mv='mv -i'
|
||||
alias rm='rm -i'
|
||||
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 执行shell内部指令,输出当前系统下的命令别名</span>
|
||||
<span class="token builtin class-name">builtin</span> <span class="token builtin class-name">alias</span>
|
||||
<span class="token builtin class-name">alias</span> <span class="token assign-left variable">cp</span><span class="token operator">=</span><span class="token string">'cp -i'</span>
|
||||
<span class="token builtin class-name">alias</span> l.<span class="token operator">=</span><span class="token string">'ls -d .* --color=tty'</span>
|
||||
|
|
@ -130,7 +155,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198849"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198849"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220150"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220150"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bunzip2,创一个bz2文件压缩包">
|
||||
<title>bunzip2 命令,Linux bunzip2 命令详解:创一个bz2文件压缩包 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198858">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220158">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,16 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bunzip2命令</strong> 解压缩由bzip2指令创建的”.bz2"压缩包。对文件进行压缩与解压缩。此命令类似于“gzip/gunzip”命令,只能对文件进行压缩。对于目录只能压缩目录下的所有文件,压缩完成后,在目录下生成以“.bz2”为后缀的压缩包。bunzip2其实是bzip2的符号链接,即软链接,因此压缩解压都可以通过bzip2实现。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bunzip2<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bunzip2(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bunzip2<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-f或--force:解压缩时,若输出的文件与现有文件同名时,预设不会覆盖现有的文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f或--force:解压缩时,若输出的文件与现有文件同名时,预设不会覆盖现有的文件;
|
||||
-k或——keep:在解压缩后,预设会删除原来的压缩文件。若要保留压缩文件,请使用此参数;
|
||||
-s或——small:降低程序执行时,内存的使用量;
|
||||
-v或——verbose:解压缩文件时,显示详细的信息;
|
||||
-l,--license,-V或——version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f或--force:解压缩时,若输出的文件与现有文件同名时,预设不会覆盖现有的文件;
|
||||
-k或——keep:在解压缩后,预设会删除原来的压缩文件。若要保留压缩文件,请使用此参数;
|
||||
-s或——small:降低程序执行时,内存的使用量;
|
||||
-v或——verbose:解压缩文件时,显示详细的信息;
|
||||
|
|
@ -70,7 +76,8 @@
|
|||
<p>.bz2压缩包:指定需要解压缩的.bz2压缩包。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将<code>/opt</code>目录下的etc.zip、var.zip和backup.zip进行压缩,设置压缩率为最高,同时在压缩完毕后不删除原始文件,显示压缩过程的详细信息。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -9vk /opt/etc.zip /opt/var.zip /opt/backup.zip
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -9vk /opt/etc.zip /opt/var.zip /opt/backup.zip
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -9vk /opt/etc.zip /opt/var.zip /opt/backup.zip
|
||||
</code></pre>
|
||||
<p>压缩完毕后,在<code>/opt</code>下就会生成相应的etc.zip.bz2、var.zip.bz2和backup.zip.bz2文件。</p>
|
||||
</div>
|
||||
|
|
@ -98,7 +105,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198858"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198858"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220158"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220158"></script>
|
||||
</body>
|
||||
</html>
|
||||
12
c/bye.html
12
c/bye.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bye,命令用于中断FTP连线并结束程序">
|
||||
<title>bye 命令,Linux bye 命令详解:命令用于中断FTP连线并结束程序 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198872">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220164">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,12 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bye命令</strong> 在ftp模式下,输入bye即可中断目前的连线作业,并结束ftp的执行。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bye
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bye
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bye
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bye
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bye
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bye
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -87,7 +89,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198873"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198873"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220164"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220164"></script>
|
||||
</body>
|
||||
</html>
|
||||
15
c/bzcat.html
15
c/bzcat.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzcat,解压缩指定的.bz2文件">
|
||||
<title>bzcat 命令,Linux bzcat 命令详解:解压缩指定的.bz2文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198880">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220173">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,17 +57,20 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzcat命令</strong> 解压缩指定的.bz2文件,并显示解压缩后的文件内容。保留原压缩文件,并且不生成解压缩后的文件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzcat<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzcat(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzcat<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>.bz2压缩文件:指定要显示内容的.bz2压缩文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将<code>/tmp/man.config</code>以bzip2格式压缩:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -z man.config
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -z man.config
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -z man.config
|
||||
</code></pre>
|
||||
<p>此时man.config会变成man.config.bz2</p>
|
||||
<p>将上面的压缩文件内容读出来:</p>
|
||||
<pre class="language-shell"><code class="language-shell">bzcat man.config.bz2
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzcat man.config.bz2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzcat man.config.bz2
|
||||
</code></pre>
|
||||
<p>此时屏幕上会显示 man.config.bz2 解压缩之后的文件内容。</p>
|
||||
</div>
|
||||
|
|
@ -95,7 +98,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198880"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198880"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220174"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220174"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzcmp,比较两个压缩包中的文件">
|
||||
<title>bzcmp 命令,Linux bzcmp 命令详解:比较两个压缩包中的文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198886">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220178">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzcmp命令</strong> 主要功能是在不真正解压缩.bz2压缩包的情况下,比较两个压缩包中的文件,省去了解压缩后在调用cmp命令的过程。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzcmp<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzcmp(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzcmp<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198887"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198887"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220179"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220179"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzdiff,直接比较两个.bz2压缩包中文件的不同">
|
||||
<title>bzdiff 命令,Linux bzdiff 命令详解:直接比较两个.bz2压缩包中文件的不同 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198891">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220183">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzdiff命令</strong> 用于直接比较两个“.bz2”压缩包中文件的不同,省去了解压缩后再调用diff命令的过程。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzdiff<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzdiff(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzdiff<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198892"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198892"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220184"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220184"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzgrep,使用正则表达式搜索.bz2压缩包中文件">
|
||||
<title>bzgrep 命令,Linux bzgrep 命令详解:使用正则表达式搜索.bz2压缩包中文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198897">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220188">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzgrep命令</strong> 使用正则表达式搜索“.bz2”压缩包中文件,将匹配的行显示到标注输出。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzgrep<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzgrep(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzgrep<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198897"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198897"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220189"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220189"></script>
|
||||
</body>
|
||||
</html>
|
||||
99
c/bzip2.html
99
c/bzip2.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzip2,将文件压缩成bz2格式">
|
||||
<title>bzip2 命令,Linux bzip2 命令详解:将文件压缩成bz2格式 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198923">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220215">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -62,7 +62,12 @@
|
|||
<p>bzip2 和 bunzip2 在缺省情况下不覆盖已有的文件。 如果想覆盖已有的文件,要指定 -f 选项。</p>
|
||||
<p>如果未指定文件名, bzip2 将压缩来自标准输入的数据并写往标准输出。在这种情况下, bzip2 会拒绝将压缩结果写往终端,因为这完全无法理解并且是没有意义的。</p>
|
||||
<p>bunzip2 (以及 bzip2 -d) 对所有指定的文件进行解压缩处理。不是由 bzip2 产生的文件将被忽略,同时发出一个警告信息。 bzip2 按下列方式由压缩文件名确定解压后的文件名:</p>
|
||||
<pre class="language-shell"><code class="language-shell">filename.bz2 解压成 filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="filename.bz2 解压成 filename
|
||||
filename.bz 解压成 filename
|
||||
filename.tbz2 解压成 filename.tar
|
||||
filename.tbz 解压成 filename.tar
|
||||
anyothername 解压成 anyothername.out
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">filename.bz2 解压成 filename
|
||||
filename.bz 解压成 filename
|
||||
filename.tbz2 解压成 filename.tar
|
||||
filename.tbz 解压成 filename.tar
|
||||
|
|
@ -73,10 +78,53 @@ anyothername 解压成 anyothername.out
|
|||
<p>bzip2 采用 32 位 CRC 校验码作自我检查,以确认解压后的文件与原始文件相同。 这可用于检测压缩文件是否损坏,并防止 bzip2 中未知的缺陷(运气好的话这种可能性非常小)。 数据损坏而未检测到的几率非常之小, 对于每个被处理的文件大约是四十亿分之一。 检查是在解压缩时进行的,因此它只能说明某个地方出问题了。 它能帮助恢复原始未压缩的数据。可以用 bzip2recover 来尝试从损坏的文件中恢复数据。</p>
|
||||
<p>返回值:正常退出返回 0, 出现环境问题返回 1 (文件未找到,非法的选项,I/O错误等), 返回 2 表明压缩文件损坏,出现导致 bzip2 紧急退出的内部一致性错误(例如缺陷)时返回 3。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> <span class="token punctuation">[</span> -cdfkqstvzVL123456789 <span class="token punctuation">]</span> <span class="token punctuation">[</span> filenames <span class="token punctuation">..</span>. <span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> <span class="token punctuation">[</span> -cdfkqstvzVL123456789 <span class="token punctuation">]</span> <span class="token punctuation">[</span> filenames <span class="token punctuation">..</span>. <span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-c --stdout
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c --stdout
|
||||
# 将数据压缩或解压缩至标准输出。
|
||||
|
||||
-d --decompress
|
||||
# 强制解压缩。 bzip2, bunzip2 以及 bzcat 实际上是同一个程序,进行何种操作将根据程序名确定。 指定该选项后将不考虑这一机制,强制 bzip2 进行解压缩。
|
||||
|
||||
-z --compress
|
||||
# -d 选项的补充:强制进行压缩操作,而不管执行的是哪个程序。
|
||||
|
||||
-t --test
|
||||
# 检查指定文件的完整性,但并不对其解压缩。 实际上将对数据进行实验性的解压缩操作,而不输出结果。
|
||||
|
||||
-f --force
|
||||
# 强制覆盖输出文件。通常 bzip2 不会覆盖已经存在的文件。该选项还强制 bzip2 打破文件的硬连接,缺省情况下 bzip2 不会这么做。
|
||||
|
||||
-k --keep
|
||||
# 在压缩或解压缩时保留输入文件(不删除这些文件)。
|
||||
|
||||
-s --small
|
||||
# 在压缩、解压缩及检查时减少内存用量。采用一种修正的算法进行压缩和测试,每个数据块仅需要 2.5 个字节。这意味着任何文件都可以在 2300k
|
||||
# 的内存中进行解压缩, 尽管速度只有通常情况下的一半。
|
||||
|
||||
# 在压缩时,-s将选定 200k 的块长度,内存用量也限制在 200k 左右, 代价是压缩率会降低。 总之,如果机器的内存较少(8兆字节或更少),
|
||||
# 可对所有操作都采用-s选项。参见下面的内存管理。
|
||||
|
||||
-q --quiet
|
||||
# 压制不重要的警告信息。属于 I/O 错误及其它严重事件的信息将不会被压制。
|
||||
|
||||
-v --verbose
|
||||
# 详尽模式 -- 显示每个被处理文件的压缩率。 命令行中更多的 -v 选项将增加详细的程度, 使 bzip2 显示出许多主要用于诊断目的信息。
|
||||
|
||||
-L --license -V --version
|
||||
# 显示软件版本,许可证条款及条件。
|
||||
|
||||
-1 to -9
|
||||
# 在压缩时将块长度设为 100 k、200 k .. 900 k。 对解压缩没有影响。参见下面的内存管理。
|
||||
|
||||
-- # 将所有后面的命令行变量看作文件名,即使这些变量以减号"-"打头。 可用这一选项处理以减号"-"打头的文件名, 例如:bzip2 -- -myfilename.
|
||||
|
||||
--repetitive-fast --repetitive-best
|
||||
# 这些选项在 0.9.5 及其以上版本中是多余的。 在较早的版本中,这两个选项对排序算法的行为提供了一些粗糙的控制,有些情况下很有用。 0.9.5
|
||||
# 及其以上版本采用了改进的算法而与这些选项无关。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c --stdout
|
||||
<span class="token comment"># 将数据压缩或解压缩至标准输出。</span>
|
||||
|
||||
-d --decompress
|
||||
|
|
@ -123,50 +171,67 @@ anyothername 解压成 anyothername.out
|
|||
<p>文件:指定要压缩的文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p><strong>压缩指定文件filename:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 filename
|
||||
或
|
||||
bzip2 -z filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> filename
|
||||
或
|
||||
<span class="token function">bzip2</span> -z filename
|
||||
</code></pre>
|
||||
<p>这里,压缩的时候不会输出,会将原来的文件filename给删除,替换成filename.bz2.如果以前有filename.bz2则不会替换并提示错误(如果想要替换则指定-f选项,例如<code>bzip2 -f filename</code>;如果filename是目录则也提醒错误不做任何操作;如果filename已经是压过的了有bz2后缀就提醒一下,不再压缩,没有bz2后缀会再次压缩。</p>
|
||||
<p><strong>解压指定的文件filename.bz2:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -d filename.bz2
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -d filename.bz2
|
||||
或
|
||||
bunzip2 filename.bz2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -d filename.bz2
|
||||
或
|
||||
bunzip2 filename.bz2
|
||||
</code></pre>
|
||||
<p>这里,解压的时候没标准输出,会将原来的文件filename.bz2给替换成filename。如果以前有filename则不会替换并提示错误(如果想要替换则指定<code>-f</code>选项,例如<code>bzip2 -df filename.bz2</code>。</p>
|
||||
<p><strong>压缩解压的时候将结果也输出:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token variable">$bzip2</span> -v filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="$bzip2 -v filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token variable">$bzip2</span> -v filename
|
||||
</code></pre>
|
||||
<p>输入之后,输出如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">filename: <span class="token number">0.119</span>:1, <span class="token number">67.200</span> bits/byte, -740.00% saved, <span class="token number">5</span> in, <span class="token number">42</span> out.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="filename: 0.119:1, 67.200 bits/byte, -740.00% saved, 5 in, 42 out.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">filename: <span class="token number">0.119</span>:1, <span class="token number">67.200</span> bits/byte, -740.00% saved, <span class="token number">5</span> in, <span class="token number">42</span> out.
|
||||
</code></pre>
|
||||
<p>这里,加上<code>-v</code>选项就会输出了,只用压缩举例了,解压的时候同理<code>bzip2 -dv filename.bz2</code>不再举例了。</p>
|
||||
<p><strong>模拟解压实际并不解压:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -tv filename.bz2
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -tv filename.bz2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -tv filename.bz2
|
||||
</code></pre>
|
||||
<p>输入之后,输出如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">filename.bz2: ok
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="filename.bz2: ok
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">filename.bz2: ok
|
||||
</code></pre>
|
||||
<p>这里,<code>-t</code>指定要进行模拟解压,不实际生成结果,也就是说类似检查文件,当然就算目录下面有filename也不会有什么错误输出了,因为它根本不会真的解压文件。为了在屏幕上输出,这里加上<code>-v</code>选项了,如果是真的解压<code>bzip2 -dv filename.bz2</code>则输出的是把"ok"替换成了"done"。</p>
|
||||
<p><strong>压缩解压的时候,除了生成结果文件,将原来的文件也保存:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -k filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -k filename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -k filename
|
||||
</code></pre>
|
||||
<p>这里,加上<code>-k</code>就保存原始的文件了,否则原始文件会被结果文件替代。只用压缩举例了,解压的时候同理<code>$bzip2 -dk filename.bz2</code>不再举例了。</p>
|
||||
<p><strong>解压到标准输出:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -dc filename.bz2
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -dc filename.bz2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -dc filename.bz2
|
||||
</code></pre>
|
||||
<p>输入之后,输出如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">hahahhaahahha
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="hahahhaahahha
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">hahahhaahahha
|
||||
</code></pre>
|
||||
<p>这里,使用<code>-c</code>指定到标准输出,输出的是文件filename的内容,不会将filename.bz2删除。</p>
|
||||
<p><strong>压缩到标准输出:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -c filename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -c filename
|
||||
bzip2: I won't write compressed data to a terminal.
|
||||
bzip2: For help, type: `bzip2 --help'.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -c filename
|
||||
bzip2: I won<span class="token string">'t write compressed data to a terminal.
|
||||
bzip2: For help, type: `bzip2 --help'</span><span class="token builtin class-name">.</span>
|
||||
</code></pre>
|
||||
<p>这里,使用<code>-c</code>指定压缩到标准输出不删除原有文件,不同的是,压缩后的文件无法输出到标准输出。</p>
|
||||
<p><strong>使用bzip2的时候将所有后面的看作文件(即使文件名以'-'开头):</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">bzip2</span> -- -myfilename
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2 -- -myfilename
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">bzip2</span> -- -myfilename
|
||||
</code></pre>
|
||||
<p>这里主要是为了防止文件名中<code>-</code>产生以为是选项的歧义。</p>
|
||||
</div>
|
||||
|
|
@ -194,7 +259,7 @@ bzip2: For help, type: `bzip2 --help'</span><span class="token builtin class-nam
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198923"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198923"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220216"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220216"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzip2recover,恢复被破坏的.bz2压缩包中的文件">
|
||||
<title>bzip2recover 命令,Linux bzip2recover 命令详解:恢复被破坏的.bz2压缩包中的文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198929">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220221">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,7 +58,8 @@
|
|||
<p><strong>bzip2recover命令</strong> 可用于恢复被破坏的“.bz2”压缩包中的文件。</p>
|
||||
<p>bzip2是以区块的方式来压缩文件,每个区块视为独立的单位。因此,当某一区块损坏时,便可利用bzip2recover,试着将文件中的区块隔开来,以便解压缩正常的区块。通常只适用在压缩文件很大的情况。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzip2recover<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzip2recover(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzip2recover<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>文件:指定要恢复数据的.bz2压缩包。</p>
|
||||
|
|
@ -87,7 +88,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198930"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198930"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220221"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220221"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzless,增强.bz2压缩包查看器">
|
||||
<title>bzless 命令,Linux bzless 命令详解:增强.bz2压缩包查看器 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198934">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220225">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzless命令</strong> 是增强“.bz2”压缩包查看器,bzless比bzmore命令功能更加强大。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzless<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzless(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzless<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>文件:指定要分屏显示的.bz2压缩包。</p>
|
||||
|
|
@ -86,7 +87,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198935"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198935"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220226"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220226"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,bzmore,查看bzip2压缩过的文本文件的内容">
|
||||
<title>bzmore 命令,Linux bzmore 命令详解:查看bzip2压缩过的文本文件的内容 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198939">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220230">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>bzmore命令</strong> 用于查看bzip2压缩过的文本文件的内容,当下一屏显示不下时可以实现分屏显示。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">bzmore<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bzmore(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">bzmore<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>文件:指定要分屏显示的.bz2压缩包。</p>
|
||||
|
|
@ -86,7 +87,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198940"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198940"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220230"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220230"></script>
|
||||
</body>
|
||||
</html>
|
||||
53
c/cal.html
53
c/cal.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cal,显示当前日历或指定日期的日历">
|
||||
<title>cal 命令,Linux cal 命令详解:显示当前日历或指定日期的日历 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198963">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220251">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -66,10 +66,17 @@
|
|||
天在这项改革被略去了, 所以那个月的日历有点不太寻常.
|
||||
</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cal</span> <span class="token punctuation">[</span> -mjy <span class="token punctuation">]</span> <span class="token punctuation">[</span> 月份 <span class="token punctuation">]</span> <span class="token punctuation">[</span> 年份 <span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cal [ -mjy ] [ 月份 ] [ 年份 ]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cal</span> <span class="token punctuation">[</span> -mjy <span class="token punctuation">]</span> <span class="token punctuation">[</span> 月份 <span class="token punctuation">]</span> <span class="token punctuation">[</span> 年份 <span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-l <span class="token comment"># 显示单月输出;</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-l # 显示单月输出;
|
||||
-3 # 显示临近三个月的日历;
|
||||
-s # 将星期日作为月的第一天;
|
||||
-m # 显示星期一作为一周的第一天.. (缺省为星期日.)
|
||||
-j # 显示儒略历的(Julian)日期 (以 1 为基的天数, 从 1 月 1 日开始计数) .
|
||||
-y # 显示当前年份的日历..
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-l <span class="token comment"># 显示单月输出;</span>
|
||||
-3 <span class="token comment"># 显示临近三个月的日历;</span>
|
||||
-s <span class="token comment"># 将星期日作为月的第一天;</span>
|
||||
-m <span class="token comment"># 显示星期一作为一周的第一天.. (缺省为星期日.)</span>
|
||||
|
|
@ -77,12 +84,22 @@
|
|||
-y <span class="token comment"># 显示当前年份的日历..</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<pre class="language-shell"><code class="language-shell">月:指定月份;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="月:指定月份;
|
||||
年:指定年份。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">月:指定月份;
|
||||
年:指定年份。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>单独执行cal命令会打印出日历:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# cal
|
||||
十二月 2013
|
||||
日 一 二 三 四 五 六
|
||||
1 2 3 4 5 6 7
|
||||
8 9 10 11 12 13 14
|
||||
15 16 17 18 19 20 21
|
||||
22 23 24 25 26 27 28
|
||||
29 30 31
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal</span>
|
||||
十二月 <span class="token number">2013</span>
|
||||
日 一 二 三 四 五 六
|
||||
<span class="token number">1</span> <span class="token number">2</span> <span class="token number">3</span> <span class="token number">4</span> <span class="token number">5</span> <span class="token number">6</span> <span class="token number">7</span>
|
||||
|
|
@ -91,7 +108,15 @@
|
|||
<span class="token number">22</span> <span class="token number">23</span> <span class="token number">24</span> <span class="token number">25</span> <span class="token number">26</span> <span class="token number">27</span> <span class="token number">28</span>
|
||||
<span class="token number">29</span> <span class="token number">30</span> <span class="token number">31</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal -j</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# cal -j
|
||||
十二月 2013
|
||||
日 一 二 三 四 五 六
|
||||
335 336 337 338 339 340 341
|
||||
342 343 344 345 346 347 348
|
||||
349 350 351 352 353 354 355
|
||||
356 357 358 359 360 361 362
|
||||
363 364 365
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal -j</span>
|
||||
十二月 <span class="token number">2013</span>
|
||||
日 一 二 三 四 五 六
|
||||
<span class="token number">335</span> <span class="token number">336</span> <span class="token number">337</span> <span class="token number">338</span> <span class="token number">339</span> <span class="token number">340</span> <span class="token number">341</span>
|
||||
|
|
@ -100,7 +125,17 @@
|
|||
<span class="token number">356</span> <span class="token number">357</span> <span class="token number">358</span> <span class="token number">359</span> <span class="token number">360</span> <span class="token number">361</span> <span class="token number">362</span>
|
||||
<span class="token number">363</span> <span class="token number">364</span> <span class="token number">365</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal -3</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# cal -3
|
||||
|
||||
九月 2021 十月 2021 十一月 2021
|
||||
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
|
||||
1 2 3 4 1 2 1 2 3 4 5 6
|
||||
5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13
|
||||
12 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20
|
||||
19 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27
|
||||
26 27 28 29 30 24 25 26 27 28 29 30 28 29 30
|
||||
31
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cal -3</span>
|
||||
|
||||
九月 <span class="token number">2021</span> 十月 <span class="token number">2021</span> 十一月 <span class="token number">2021</span>
|
||||
日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六
|
||||
|
|
@ -136,7 +171,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198964"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198964"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220252"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220252"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cancel,取消已存在的打印任务">
|
||||
<title>cancel 命令,Linux cancel 命令详解:取消已存在的打印任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198970">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220257">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,16 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cancel命令</strong> 用于取消已存在的打印任务。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cancel<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cancel(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cancel<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a:取消所有打印任务;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a:取消所有打印任务;
|
||||
-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
-h:指定连接的服务器名和端口号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a:取消所有打印任务;
|
||||
-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
|
|
@ -93,7 +99,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198971"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198971"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220258"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220258"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
c/cat.html
40
c/cat.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cat,连接多个文件并打印到标准输出。">
|
||||
<title>cat 命令,Linux cat 命令详解:连接多个文件并打印到标准输出。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159198984">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220271">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="cat"><a class="anchor" aria-hidden="true" tabindex="-1" href="#cat"><span class="octicon octicon-link"></span></a>cat</h1>
|
||||
<p>连接多个文件并打印到标准输出。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>FILE<span class="token punctuation">]</span><span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat [OPTION]... [FILE]...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>FILE<span class="token punctuation">]</span><span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -66,7 +67,22 @@
|
|||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<p>FILE(可选):要处理的文件,可以为一或多个。</p>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">长选项与短选项等价
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="长选项与短选项等价
|
||||
|
||||
-A, --show-all 等价于"-vET"组合选项。
|
||||
-b, --number-nonblank 只对非空行编号,从1开始编号,覆盖"-n"选项。
|
||||
-e 等价于"-vE"组合选项。
|
||||
-E, --show-ends 在每行的结尾显示'$'字符。
|
||||
-n, --number 对所有行编号,从1开始编号。
|
||||
-s, --squeeze-blank 压缩连续的空行到一行。
|
||||
-t 等价于"-vT"组合选项。
|
||||
-T, --show-tabs 使用"^I"表示TAB(制表符)。
|
||||
-u POSIX兼容性选项,无意义。
|
||||
-v, --show-nonprinting 使用"^"和"M-"符号显示控制字符,除了LFD(line feed,即换行符'\n')和TAB(制表符)。
|
||||
|
||||
--help 显示帮助信息并退出。
|
||||
--version 显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">长选项与短选项等价
|
||||
|
||||
-A, --show-all 等价于<span class="token string">"-vET"</span>组合选项。
|
||||
-b, --number-nonblank 只对非空行编号,从1开始编号,覆盖<span class="token string">"-n"</span>选项。
|
||||
|
|
@ -85,7 +101,19 @@
|
|||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回状态为成功除非给出了非法选项或非法参数。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 合并显示多个文件</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 合并显示多个文件
|
||||
cat ./1.log ./2.log ./3.log
|
||||
# 显示文件中的非打印字符、tab、换行符
|
||||
cat -A test.log
|
||||
# 压缩文件的空行
|
||||
cat -s test.log
|
||||
# 显示文件并在所有行开头附加行号
|
||||
cat -n test.log
|
||||
# 显示文件并在所有非空行开头附加行号
|
||||
cat -b test.log
|
||||
# 将标准输入的内容和文件内容一并显示
|
||||
echo '######' |cat - test.log
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 合并显示多个文件</span>
|
||||
<span class="token function">cat</span> ./1.log ./2.log ./3.log
|
||||
<span class="token comment"># 显示文件中的非打印字符、tab、换行符</span>
|
||||
<span class="token function">cat</span> -A test.log
|
||||
|
|
@ -133,7 +161,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159198985"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159198985"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220271"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220271"></script>
|
||||
</body>
|
||||
</html>
|
||||
51
c/cd.html
51
c/cd.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cd,切换用户当前工作目录。">
|
||||
<title>cd 命令,Linux cd 命令详解:切换用户当前工作目录。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199003">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220286">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="cd"><a class="anchor" aria-hidden="true" tabindex="-1" href="#cd"><span class="octicon octicon-link"></span></a>cd</h1>
|
||||
<p>切换用户当前工作目录。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">cd</span> <span class="token punctuation">[</span>-L<span class="token operator">|</span><span class="token punctuation">[</span>-P <span class="token punctuation">[</span>-e<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">[</span>dir<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cd [-L|[-P [-e]]] [dir]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">cd</span> <span class="token punctuation">[</span>-L<span class="token operator">|</span><span class="token punctuation">[</span>-P <span class="token punctuation">[</span>-e<span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">[</span>dir<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -68,14 +69,23 @@
|
|||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<p>dir(可选):指定要切换到的目录。</p>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">-L (默认值)如果要切换到的目标目录是一个符号连接,那么切换到符号连接的目录。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-L (默认值)如果要切换到的目标目录是一个符号连接,那么切换到符号连接的目录。
|
||||
-P 如果要切换到的目标目录是一个符号连接,那么切换到它指向的物理位置目录。
|
||||
- 当前工作目录将被切换到环境变量OLDPWD所表示的目录,也就是前一个工作目录。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-L (默认值)如果要切换到的目标目录是一个符号连接,那么切换到符号连接的目录。
|
||||
-P 如果要切换到的目标目录是一个符号连接,那么切换到它指向的物理位置目录。
|
||||
- 当前工作目录将被切换到环境变量<span class="token environment constant">OLDPWD</span>所表示的目录,也就是前一个工作目录。
|
||||
</code></pre>
|
||||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回状态为成功除非无法进入指定的目录。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">cd</span> <span class="token comment"># 进入用户主目录;</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cd # 进入用户主目录;
|
||||
cd / # 进入根目录
|
||||
cd ~ # 进入用户主目录;
|
||||
cd .. # 返回上级目录(若当前目录为“/“,则执行完后还在“/";".."为上级目录的意思);
|
||||
cd ../.. # 返回上两级目录;
|
||||
cd !$ # 把上个命令的参数作为cd参数使用。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">cd</span> <span class="token comment"># 进入用户主目录;</span>
|
||||
<span class="token builtin class-name">cd</span> / <span class="token comment"># 进入根目录</span>
|
||||
<span class="token builtin class-name">cd</span> ~ <span class="token comment"># 进入用户主目录;</span>
|
||||
<span class="token builtin class-name">cd</span> <span class="token punctuation">..</span> <span class="token comment"># 返回上级目录(若当前目录为“/“,则执行完后还在“/";".."为上级目录的意思);</span>
|
||||
|
|
@ -83,13 +93,28 @@
|
|||
<span class="token builtin class-name">cd</span> <span class="token operator">!</span>$ <span class="token comment"># 把上个命令的参数作为cd参数使用。</span>
|
||||
</code></pre>
|
||||
<p>关于切换到上一个工作目录的说明</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">cd</span> -
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cd -
|
||||
# 命令会首先显示要切换到的目标目录,然后再进入。
|
||||
cd ${OLDPWD}
|
||||
# 命令会直接切换到上一个工作目录。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">cd</span> -
|
||||
<span class="token comment"># 命令会首先显示要切换到的目标目录,然后再进入。</span>
|
||||
<span class="token builtin class-name">cd</span> <span class="token variable">${<span class="token environment constant">OLDPWD</span>}</span>
|
||||
<span class="token comment"># 命令会直接切换到上一个工作目录。</span>
|
||||
</code></pre>
|
||||
<p>关于<code>CDPATH</code></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 设置桌面文件夹作为CDPATH的值。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 设置桌面文件夹作为CDPATH的值。
|
||||
CDPATH='~/Desktop'
|
||||
# 假设我们接下来要演示涉及到的路径~和~/Desktop下没有test3文件夹,现在新建它们。
|
||||
mkdir ~/test3
|
||||
mkdir ~/Desktop/test3
|
||||
# 进入~目录。
|
||||
cd ~
|
||||
# 进入test3目录。
|
||||
cd test3
|
||||
# 执行后显示~/Desktop/test3并进入该目录,而不是~目录的test3目录。
|
||||
# 如果CDPATH存在值,那么优先在CDPATH中查找并进入第一个匹配成功的,如果全部失败那么最后尝试当前目录。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 设置桌面文件夹作为CDPATH的值。</span>
|
||||
<span class="token assign-left variable">CDPATH</span><span class="token operator">=</span><span class="token string">'~/Desktop'</span>
|
||||
<span class="token comment"># 假设我们接下来要演示涉及到的路径~和~/Desktop下没有test3文件夹,现在新建它们。</span>
|
||||
<span class="token function">mkdir</span> ~/test3
|
||||
|
|
@ -102,7 +127,15 @@
|
|||
<span class="token comment"># 如果CDPATH存在值,那么优先在CDPATH中查找并进入第一个匹配成功的,如果全部失败那么最后尝试当前目录。</span>
|
||||
</code></pre>
|
||||
<p>关于<code>cdable_vars</code></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 打开选项。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 打开选项。
|
||||
shopt -s cdable_vars
|
||||
# 假设当前路径以及CDPATH没有名为new_var的目录。
|
||||
new_var='~/Desktop'
|
||||
# 尝试进入。
|
||||
cd new_var
|
||||
# 关闭选项。
|
||||
shopt -u cdable_vars
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 打开选项。</span>
|
||||
<span class="token builtin class-name">shopt</span> -s cdable_vars
|
||||
<span class="token comment"># 假设当前路径以及CDPATH没有名为new_var的目录。</span>
|
||||
<span class="token assign-left variable">new_var</span><span class="token operator">=</span><span class="token string">'~/Desktop'</span>
|
||||
|
|
@ -145,7 +178,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199004"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199004"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220287"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220287"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cdrecord,Linux系统下光盘刻录功能命令">
|
||||
<title>cdrecord 命令,Linux cdrecord 命令详解:Linux系统下光盘刻录功能命令 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199014">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220296">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,16 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cdrecord命令</strong> 用于Linux系统下光盘刻录,它支持cd和DVD格式。linux下一般都带有cdrecord软件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cdrecord<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cdrecord(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cdrecord<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-v:显示刻录光盘的详细过程;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-v:显示刻录光盘的详细过程;
|
||||
-eject:刻录完成后弹出光盘;
|
||||
speed=<刻录倍速>:指定光盘刻录的倍速;
|
||||
dev=<刻录机设备号>:指定使用“-scanbus”参数扫描到的刻录机的设备号;
|
||||
-scanbus:扫描系统中可用的刻录机。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-v:显示刻录光盘的详细过程;
|
||||
-eject:刻录完成后弹出光盘;
|
||||
<span class="token assign-left variable">speed</span><span class="token operator">=</span><span class="token operator"><</span>刻录倍速<span class="token operator">></span>:指定光盘刻录的倍速;
|
||||
<span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token operator"><</span>刻录机设备号<span class="token operator">></span>:指定使用“-scanbus”参数扫描到的刻录机的设备号;
|
||||
|
|
@ -70,7 +76,13 @@
|
|||
<p>ISO文件:指定刻录光盘使用的ISO映像文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>查看系统所有 CD-R(w) 设备:</p>
|
||||
<pre class="language-shell"><code class="language-shell">cdrecord -scanbus
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cdrecord -scanbus
|
||||
scsibus0:
|
||||
0,0,0 0) *
|
||||
0,1,0 1) *
|
||||
0,2,0 2) *
|
||||
0,3,0 3) 'HP ' 'CD-Writer+ 9200 ' '1.0c' Removable CD-ROM
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cdrecord -scanbus
|
||||
scsibus0:
|
||||
<span class="token number">0,0</span>,0 <span class="token number">0</span><span class="token punctuation">)</span> *
|
||||
<span class="token number">0,1</span>,0 <span class="token number">1</span><span class="token punctuation">)</span> *
|
||||
|
|
@ -78,7 +90,8 @@ scsibus0:
|
|||
<span class="token number">0,3</span>,0 <span class="token number">3</span><span class="token punctuation">)</span> <span class="token string">'HP '</span> <span class="token string">'CD-Writer+ 9200 '</span> <span class="token string">'1.0c'</span> Removable CD-ROM
|
||||
</code></pre>
|
||||
<p>用iso文件刻录一张光盘:</p>
|
||||
<pre class="language-shell"><code class="language-shell">cdrecord -v -eject <span class="token assign-left variable">speed</span><span class="token operator">=</span><span class="token number">4</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token number">0,3</span>,0 backup.iso
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cdrecord -v -eject speed=4 dev=0,3,0 backup.iso
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cdrecord -v -eject <span class="token assign-left variable">speed</span><span class="token operator">=</span><span class="token number">4</span> <span class="token assign-left variable">dev</span><span class="token operator">=</span><span class="token number">0,3</span>,0 backup.iso
|
||||
</code></pre>
|
||||
<p>参数解释</p>
|
||||
<ul>
|
||||
|
|
@ -87,7 +100,8 @@ scsibus0:
|
|||
<li>speed=4 dev=0,3,0:四速刻录到HP CD-writer设备上。</li>
|
||||
</ul>
|
||||
<p>擦写光驱:</p>
|
||||
<pre class="language-shell"><code class="language-shell">cdrecord --dev<span class="token operator">=</span><span class="token number">0,3</span>,0 --blank<span class="token operator">=</span>fast
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cdrecord --dev=0,3,0 --blank=fast
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cdrecord --dev<span class="token operator">=</span><span class="token number">0,3</span>,0 --blank<span class="token operator">=</span>fast
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -114,7 +128,7 @@ scsibus0:
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199015"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199015"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220298"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220298"></script>
|
||||
</body>
|
||||
</html>
|
||||
69
c/chage.html
69
c/chage.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chage,修改帐号和密码的有效期限">
|
||||
<title>chage 命令,Linux chage 命令详解:修改帐号和密码的有效期限 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199027">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220310">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,18 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chage命令</strong> 是用来修改帐号和密码的有效期限。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chage <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> 用户名
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chage [选项] 用户名
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chage <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> 用户名
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-m:密码可更改的最小天数。为零时代表任何时候都可以更改密码。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-m:密码可更改的最小天数。为零时代表任何时候都可以更改密码。
|
||||
-M:密码保持有效的最大天数。
|
||||
-w:用户密码到期前,提前收到警告信息的天数。
|
||||
-E:帐号到期的日期。过了这天,此帐号将不可用。
|
||||
-d:上一次更改的日期。
|
||||
-i:停滞时期。如果一个密码已过期这些天,那么此帐号将不可用。
|
||||
-l:例出当前的设置。由非特权用户来确定他们的密码或帐号何时过期。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-m:密码可更改的最小天数。为零时代表任何时候都可以更改密码。
|
||||
-M:密码保持有效的最大天数。
|
||||
-w:用户密码到期前,提前收到警告信息的天数。
|
||||
-E:帐号到期的日期。过了这天,此帐号将不可用。
|
||||
|
|
@ -70,13 +78,25 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>可以编辑<code>/etc/login.defs</code>来设定几个参数,以后设置口令默认就按照参数设定为准:</p>
|
||||
<pre class="language-shell"><code class="language-shell">PASS_MAX_DAYS <span class="token number">99999</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="PASS_MAX_DAYS 99999
|
||||
PASS_MIN_DAYS 0
|
||||
PASS_MIN_LEN 5
|
||||
PASS_WARN_AGE 7
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">PASS_MAX_DAYS <span class="token number">99999</span>
|
||||
PASS_MIN_DAYS <span class="token number">0</span>
|
||||
PASS_MIN_LEN <span class="token number">5</span>
|
||||
PASS_WARN_AGE <span class="token number">7</span>
|
||||
</code></pre>
|
||||
<p>当然在<code>/etc/default/useradd</code>可以找到如下2个参数进行设置:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># useradd defaults file</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# useradd defaults file
|
||||
GROUP=100
|
||||
HOME=/home
|
||||
INACTIVE=-1
|
||||
EXPIRE=
|
||||
SHELL=/bin/bash
|
||||
SKEL=/etc/skel
|
||||
CREATE_MAIL_SPOOL=yes
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># useradd defaults file</span>
|
||||
<span class="token assign-left variable">GROUP</span><span class="token operator">=</span><span class="token number">100</span>
|
||||
<span class="token assign-left variable"><span class="token environment constant">HOME</span></span><span class="token operator">=</span>/home
|
||||
<span class="token assign-left variable">INACTIVE</span><span class="token operator">=</span>-1
|
||||
|
|
@ -87,7 +107,16 @@ PASS_WARN_AGE <span class="token number">7</span>
|
|||
</code></pre>
|
||||
<p>通过修改配置文件,能对之后新建用户起作用,而目前系统已经存在的用户,则直接用chage来配置。</p>
|
||||
<p>我的服务器root帐户密码策略信息如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chage -l root
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chage -l root
|
||||
|
||||
最近一次密码修改时间 : 3月 12, 2013
|
||||
密码过期时间 :从不
|
||||
密码失效时间 :从不
|
||||
帐户过期时间 :从不
|
||||
两次改变密码之间相距的最小天数 :0
|
||||
两次改变密码之间相距的最大天数 :99999
|
||||
在密码过期之前警告的天数 :7
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chage -l root
|
||||
|
||||
最近一次密码修改时间 : <span class="token number">3</span>月 <span class="token number">12</span>, <span class="token number">2013</span>
|
||||
密码过期时间 :从不
|
||||
|
|
@ -98,7 +127,17 @@ PASS_WARN_AGE <span class="token number">7</span>
|
|||
在密码过期之前警告的天数 :7
|
||||
</code></pre>
|
||||
<p>我可以通过如下命令修改我的密码过期时间:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chage -M <span class="token number">60</span> root
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chage -M 60 root
|
||||
chage -l root
|
||||
|
||||
最近一次密码修改时间 : 3月 12, 2013
|
||||
密码过期时间 : 5月 11, 2013
|
||||
密码失效时间 :从不
|
||||
帐户过期时间 :从不
|
||||
两次改变密码之间相距的最小天数 :0
|
||||
两次改变密码之间相距的最大天数 :60
|
||||
在密码过期之前警告的天数 :9
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chage -M <span class="token number">60</span> root
|
||||
chage -l root
|
||||
|
||||
最近一次密码修改时间 : <span class="token number">3</span>月 <span class="token number">12</span>, <span class="token number">2013</span>
|
||||
|
|
@ -110,7 +149,17 @@ chage -l root
|
|||
在密码过期之前警告的天数 :9
|
||||
</code></pre>
|
||||
<p>然后通过如下命令设置密码失效时间:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chage -I <span class="token number">5</span> root
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chage -I 5 root
|
||||
chage -l root
|
||||
|
||||
最近一次密码修改时间 : 3月 12, 2013
|
||||
密码过期时间 : 5月 11, 2013
|
||||
密码失效时间 : 5月 16, 2013
|
||||
帐户过期时间 :从不
|
||||
两次改变密码之间相距的最小天数 :0
|
||||
两次改变密码之间相距的最大天数 :60
|
||||
在密码过期之前警告的天数 :9
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chage -I <span class="token number">5</span> root
|
||||
chage -l root
|
||||
|
||||
最近一次密码修改时间 : <span class="token number">3</span>月 <span class="token number">12</span>, <span class="token number">2013</span>
|
||||
|
|
@ -147,7 +196,7 @@ chage -l root
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199028"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199028"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220311"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220311"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chattr,用来改变文件属性">
|
||||
<title>chattr 命令,Linux chattr 命令详解:用来改变文件属性 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199038">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220319">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,19 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chattr命令</strong> 用来改变文件属性。这项指令可改变存放在ext2文件系统上的文件或目录属性,这些属性共有以下8种模式:</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chattr<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chattr(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chattr<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">a:让文件或目录仅供附加用途;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="a:让文件或目录仅供附加用途;
|
||||
b:不更新文件或目录的最后存取时间;
|
||||
c:将文件或目录压缩后存放;
|
||||
d:将文件或目录排除在倾倒操作之外;
|
||||
i:不得任意更动文件或目录;
|
||||
s:保密性删除文件或目录;
|
||||
S:即时更新文件或目录;
|
||||
u:预防意外删除。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">a:让文件或目录仅供附加用途;
|
||||
b:不更新文件或目录的最后存取时间;
|
||||
c:将文件或目录压缩后存放;
|
||||
d:将文件或目录排除在倾倒操作之外;
|
||||
|
|
@ -69,7 +78,13 @@ s:保密性删除文件或目录;
|
|||
S:即时更新文件或目录;
|
||||
u:预防意外删除。
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell">-R:递归处理,将指令目录下的所有文件及子目录一并处理;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-R:递归处理,将指令目录下的所有文件及子目录一并处理;
|
||||
-v<版本编号>:设置文件或目录版本;
|
||||
-V:显示指令执行过程;
|
||||
+<属性>:开启文件或目录的该项属性;
|
||||
-<属性>:关闭文件或目录的该项属性;
|
||||
=<属性>:指定文件或目录的该项属性。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-R:递归处理,将指令目录下的所有文件及子目录一并处理;
|
||||
-v<span class="token operator"><</span>版本编号<span class="token operator">></span>:设置文件或目录版本;
|
||||
-V:显示指令执行过程;
|
||||
+<span class="token operator"><</span>属性<span class="token operator">></span>:开启文件或目录的该项属性;
|
||||
|
|
@ -78,11 +93,13 @@ u:预防意外删除。
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>用chattr命令防止系统中某个关键文件被修改:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chattr +i /etc/fstab
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chattr +i /etc/fstab
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chattr +i /etc/fstab
|
||||
</code></pre>
|
||||
<p>然后试一下rm、mv、rename等命令操作于该文件,都是得到Operation not permitted的结果。</p>
|
||||
<p>让某个文件只能往里面追加内容,不能删除,一些日志文件适用于这种操作:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chattr +a /data1/user_act.log
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chattr +a /data1/user_act.log
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chattr +a /data1/user_act.log
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -109,7 +126,7 @@ u:预防意外删除。
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199039"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199039"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220320"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220320"></script>
|
||||
</body>
|
||||
</html>
|
||||
44
c/chcon.html
44
c/chcon.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chcon,修改对象(文件)的安全上下文">
|
||||
<title>chcon 命令,Linux chcon 命令详解:修改对象(文件)的安全上下文 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199048">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220330">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,12 +57,23 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chcon命令</strong> 是修改对象(文件)的安全上下文,比如:用户、角色、类型、安全级别。也就是将每个文件的安全环境变更至指定环境。使用<code>--reference</code>选项时,把指定文件的安全环境设置为与参考文件相同。chcon命令位于<code>/usr/bin/chcon</code>。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chcon <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">..</span>. 环境 文件<span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chcon [选项]... 环境 文件...
|
||||
chcon [选项]... [-u 用户] [-r 角色] [-l 范围] [-t 类型] 文件...
|
||||
chcon [选项]... --reference=参考文件 文件...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chcon <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">..</span>. 环境 文件<span class="token punctuation">..</span>.
|
||||
chcon <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>-u 用户<span class="token punctuation">]</span> <span class="token punctuation">[</span>-r 角色<span class="token punctuation">]</span> <span class="token punctuation">[</span>-l 范围<span class="token punctuation">]</span> <span class="token punctuation">[</span>-t 类型<span class="token punctuation">]</span> 文件<span class="token punctuation">..</span>.
|
||||
chcon <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">..</span>. --reference<span class="token operator">=</span>参考文件 文件<span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-h, --no-dereference:影响符号连接而非引用的文件。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-h, --no-dereference:影响符号连接而非引用的文件。
|
||||
--reference=参考文件:使用指定参考文件的安全环境,而非指定值。
|
||||
-R, --recursive:递归处理所有的文件及子目录。
|
||||
-v, --verbose:为处理的所有文件显示诊断信息。
|
||||
-u, --user=用户:设置指定用户的目标安全环境。
|
||||
-r, --role=角色:设置指定角色的目标安全环境。
|
||||
-t, --type=类型:设置指定类型的目标安全环境。
|
||||
-l, --range=范围:设置指定范围的目标安全环境。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-h, --no-dereference:影响符号连接而非引用的文件。
|
||||
--reference<span class="token operator">=</span>参考文件:使用指定参考文件的安全环境,而非指定值。
|
||||
-R, --recursive:递归处理所有的文件及子目录。
|
||||
-v, --verbose:为处理的所有文件显示诊断信息。
|
||||
|
|
@ -72,7 +83,12 @@ chcon <span class="token punctuation">[</span>选项<span class="token punctuati
|
|||
-l, --range<span class="token operator">=</span>范围:设置指定范围的目标安全环境。
|
||||
</code></pre>
|
||||
<p>以下选项是在指定了<code>-R</code>选项时被用于设置如何穿越目录结构体系。如果您指定了多于一个选项,那么只有最后一个会生效。</p>
|
||||
<pre class="language-shell"><code class="language-shell">-H:如果命令行参数是一个通到目录的符号链接,则遍历符号链接。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-H:如果命令行参数是一个通到目录的符号链接,则遍历符号链接。
|
||||
-L:遍历每一个遇到的通到目录的符号链接。
|
||||
-P:不遍历任何符号链接(默认)。
|
||||
--help:显示此帮助信息并退出。
|
||||
--version:显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-H:如果命令行参数是一个通到目录的符号链接,则遍历符号链接。
|
||||
-L:遍历每一个遇到的通到目录的符号链接。
|
||||
-P:不遍历任何符号链接(默认)。
|
||||
--help:显示此帮助信息并退出。
|
||||
|
|
@ -80,20 +96,26 @@ chcon <span class="token punctuation">[</span>选项<span class="token punctuati
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>如果你想把这个ftp共享给匿名用户的话,需要开启以下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chcon -R -t public_content_t /var/ftp
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chcon -R -t public_content_t /var/ftp
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chcon -R -t public_content_t /var/ftp
|
||||
</code></pre>
|
||||
<p>如果你想让你设置的FTP目录可以上传文件的话,SELINUX需要设置:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chcon -t public_content_rw_t /var/ftp/incoming
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chcon -t public_content_rw_t /var/ftp/incoming
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chcon -t public_content_rw_t /var/ftp/incoming
|
||||
</code></pre>
|
||||
<p>允许用户HHTP访问其家目录,该设定限仅于用户的家目录主页:</p>
|
||||
<pre class="language-shell"><code class="language-shell">setsebool -P httpd_enable_homedirs <span class="token number">1</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="setsebool -P httpd_enable_homedirs 1
|
||||
chcon -R -t httpd_sys_content_t ~user/public_html
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">setsebool -P httpd_enable_homedirs <span class="token number">1</span>
|
||||
chcon -R -t httpd_sys_content_t ~user/public_html
|
||||
</code></pre>
|
||||
<p>如果你希望将samba目录共享给其他用户,你需要设置:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chcon -t samba_share_t /directory
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chcon -t samba_share_t /directory
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chcon -t samba_share_t /directory
|
||||
</code></pre>
|
||||
<p>共享rsync目录时:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chcon -t public_content_t /directories
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chcon -t public_content_t /directories
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chcon -t public_content_t /directories
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -120,7 +142,7 @@ chcon -R -t httpd_sys_content_t ~user/public_html
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199049"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199049"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220332"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220332"></script>
|
||||
</body>
|
||||
</html>
|
||||
41
c/chfn.html
41
c/chfn.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chfn,用来改变finger命令显示的信息">
|
||||
<title>chfn 命令,Linux chfn 命令详解:用来改变finger命令显示的信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199058">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220343">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chfn命令</strong> 用来改变finger命令显示的信息。这些信息都存放在/etc目录里的passwd文件里。若不指定任何选项,则chfn命令会进入问答式界面。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chfn<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chfn(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chfn<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-f<span class="token operator"><</span>真实姓名<span class="token operator">></span>或--full-name<span class="token operator"><</span>真实姓名<span class="token operator">></span>:设置真实姓名;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f<真实姓名>或--full-name<真实姓名>:设置真实姓名;
|
||||
-h<家中电话>或--home-phone<家中电话>:设置家中的电话号码;
|
||||
-o<办公地址>或--office<办公地址>:设置办公室的地址;
|
||||
-p<办公电话>或--office-phone<办公电话>:设置办公室的电话号码;
|
||||
-u或--help:在线帮助;
|
||||
-v或-version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f<span class="token operator"><</span>真实姓名<span class="token operator">></span>或--full-name<span class="token operator"><</span>真实姓名<span class="token operator">></span>:设置真实姓名;
|
||||
-h<span class="token operator"><</span>家中电话<span class="token operator">></span>或--home-phone<span class="token operator"><</span>家中电话<span class="token operator">></span>:设置家中的电话号码;
|
||||
-o<span class="token operator"><</span>办公地址<span class="token operator">></span>或--office<span class="token operator"><</span>办公地址<span class="token operator">></span>:设置办公室的地址;
|
||||
-p<span class="token operator"><</span>办公电话<span class="token operator">></span>或--office-phone<span class="token operator"><</span>办公电话<span class="token operator">></span>:设置办公室的电话号码;
|
||||
|
|
@ -71,7 +78,15 @@
|
|||
<p>用户名:指定要改变finger信息的用户名。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>范例1,改变finger信息:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost Desktop<span class="token punctuation">]</span><span class="token comment"># chfn</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost Desktop]# chfn
|
||||
Changing finger information for root.
|
||||
Name [root]: jack
|
||||
Office []: hn
|
||||
Office Phone []: 888888
|
||||
Home Phone []: 9999999
|
||||
|
||||
Finger information changed.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost Desktop<span class="token punctuation">]</span><span class="token comment"># chfn</span>
|
||||
Changing finger information <span class="token keyword">for</span> root.
|
||||
Name <span class="token punctuation">[</span>root<span class="token punctuation">]</span>: jack
|
||||
Office <span class="token punctuation">[</span><span class="token punctuation">]</span>: hn
|
||||
|
|
@ -81,12 +96,22 @@ Home Phone <span class="token punctuation">[</span><span class="token punctuatio
|
|||
Finger information changed.
|
||||
</code></pre>
|
||||
<p>范例2,改变账号真实姓名:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost Desktop<span class="token punctuation">]</span><span class="token comment"># chfn -f jack</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost Desktop]# chfn -f jack
|
||||
Changing finger information for root.
|
||||
Finger information changed.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost Desktop<span class="token punctuation">]</span><span class="token comment"># chfn -f jack</span>
|
||||
Changing finger information <span class="token keyword">for</span> root.
|
||||
Finger information changed.
|
||||
</code></pre>
|
||||
<p>范例3:</p>
|
||||
<pre class="language-shell"><code class="language-shell">shell<span class="token operator">>></span> chfn
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="shell>> chfn
|
||||
Changing finger information for user
|
||||
Password: [del]
|
||||
Name[]:linuxde ### 提供 finger 时的资料
|
||||
Office[]:NCCU
|
||||
Office Phone[]: [del]
|
||||
Home Phone[]: [del]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">shell<span class="token operator">>></span> chfn
|
||||
Changing finger information <span class="token keyword">for</span> user
|
||||
Password: <span class="token punctuation">[</span>del<span class="token punctuation">]</span>
|
||||
Name<span class="token punctuation">[</span><span class="token punctuation">]</span>:linuxde <span class="token comment">### 提供 finger 时的资料</span>
|
||||
|
|
@ -119,7 +144,7 @@ Home Phone<span class="token punctuation">[</span><span class="token punctuation
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199059"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199059"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220343"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220343"></script>
|
||||
</body>
|
||||
</html>
|
||||
27
c/chgrp.html
27
c/chgrp.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chgrp,用来变更文件或目录的所属群组">
|
||||
<title>chgrp 命令,Linux chgrp 命令详解:用来变更文件或目录的所属群组 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199067">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220351">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,10 +58,21 @@
|
|||
<p><strong>chgrp命令</strong> 用来改变文件或目录所属的用户组。该命令用来改变指定文件所属的用户组。其中,组名可以是用户组的id,也可以是用户组的组名。文件名可以 是由空格分开的要改变属组的文件列表,也可以是由通配符描述的文件集合。如果用户不是该文件的文件主或超级用户(root),则不能改变该文件的组。</p>
|
||||
<p>在UNIX系统家族里,文件或目录权限的掌控以拥有者及所属群组来管理。您可以使用chgrp指令去变更文件与目录的所属群组,设置方式采用群组名称或群组识别码皆可。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chgrp</span> <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">[</span>组群<span class="token punctuation">]</span><span class="token punctuation">[</span>文件<span class="token operator">|</span>目录<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chgrp [选项][组群][文件|目录]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chgrp</span> <span class="token punctuation">[</span>选项<span class="token punctuation">]</span><span class="token punctuation">[</span>组群<span class="token punctuation">]</span><span class="token punctuation">[</span>文件<span class="token operator">|</span>目录<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-R 递归式地改变指定目录及其下的所有子目录和文件的所属的组
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-R 递归式地改变指定目录及其下的所有子目录和文件的所属的组
|
||||
-c或——changes:效果类似“-v”参数,但仅回报更改的部分;
|
||||
-f或--quiet或——silent:不显示错误信息;
|
||||
-h或--no-dereference:只对符号连接的文件作修改,而不是该其他任何相关文件;
|
||||
-H如果命令行参数是一个通到目录的符号链接,则遍历符号链接
|
||||
-R或——recursive:递归处理,将指令目录下的所有文件及子目录一并处理;
|
||||
-L遍历每一个遇到的通到目录的符号链接
|
||||
-P不遍历任何符号链接(默认)
|
||||
-v或——verbose:显示指令执行过程;
|
||||
--reference=<参考文件或目录>:把指定文件或目录的所属群组全部设成和参考文件或目录的所属群组相同;
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-R 递归式地改变指定目录及其下的所有子目录和文件的所属的组
|
||||
-c或——changes:效果类似“-v”参数,但仅回报更改的部分;
|
||||
-f或--quiet或——silent:不显示错误信息;
|
||||
-h或--no-dereference:只对符号连接的文件作修改,而不是该其他任何相关文件;
|
||||
|
|
@ -79,10 +90,12 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将<code>/usr/meng</code>及其子目录下的所有文件的用户组改为mengxin</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chgrp</span> -R mengxin /usr/meng
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chgrp -R mengxin /usr/meng
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chgrp</span> -R mengxin /usr/meng
|
||||
</code></pre>
|
||||
<p>更改文件ah的组群所有者为 <code>newuser</code></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@rhel ~<span class="token punctuation">]</span><span class="token comment"># chgrp newuser ah</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@rhel ~]# chgrp newuser ah
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@rhel ~<span class="token punctuation">]</span><span class="token comment"># chgrp newuser ah</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -109,7 +122,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199068"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199068"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220352"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220352"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chkconfig,检查或设置系统的各种服务">
|
||||
<title>chkconfig 命令,Linux chkconfig 命令详解:检查或设置系统的各种服务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199097">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220374">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,14 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chkconfig命令</strong> 检查、设置系统的各种服务。这是Red Hat公司遵循GPL规则所开发的程序,它可查询操作系统在每一个执行等级中会执行哪些系统服务,其中包括各类常驻服务。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chkconfig<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chkconfig(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chkconfig<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据;
|
||||
--del:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据;
|
||||
--level<等级代号>:指定读系统服务要在哪一个执行等级中开启或关毕。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--add:增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据;
|
||||
--del:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据;
|
||||
--level<span class="token operator"><</span>等级代号<span class="token operator">></span>:指定读系统服务要在哪一个执行等级中开启或关毕。
|
||||
</code></pre>
|
||||
|
|
@ -88,12 +92,25 @@
|
|||
<p>运行级文件:</p>
|
||||
<p>每个被chkconfig管理的服务需要在对应的init.d下的脚本加上两行或者更多行的注释。第一行告诉chkconfig缺省启动的运行级以及启动和停止的优先级。如果某服务缺省不在任何运行级启动,那么使用<code>-</code>代替运行级。第二行对服务进行描述,可以用<code>\</code>跨行注释。</p>
|
||||
<p>例如random.init包含三行:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># chkconfig: 2345 20 80</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# chkconfig: 2345 20 80
|
||||
# description: Saves and restores system entropy pool for \
|
||||
# higher quality random number generation.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># chkconfig: 2345 20 80</span>
|
||||
<span class="token comment"># description: Saves and restores system entropy pool for \</span>
|
||||
<span class="token comment"># higher quality random number generation.</span>
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chkconfig</span> --list <span class="token comment">#列出所有的系统服务。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chkconfig --list #列出所有的系统服务。
|
||||
chkconfig --add httpd #增加httpd服务。
|
||||
chkconfig --del httpd #删除httpd服务。
|
||||
chkconfig --level httpd 2345 on #设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态。
|
||||
chkconfig --list # 列出系统所有的服务启动情况。
|
||||
chkconfig --list mysqld # 列出mysqld服务设置情况。
|
||||
chkconfig --level 35 mysqld on # 设定mysqld在等级3和5为开机运行服务,--level 35表示操作只在等级3和5执行,on表示启动,off表示关闭。
|
||||
chkconfig mysqld on # 设定mysqld在各等级为on,“各等级”包括2、3、4、5等级。
|
||||
|
||||
chkconfig –level redis 2345 on # 把redis在运行级别为2、3、4、5的情况下都是on(开启)的状态。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chkconfig</span> --list <span class="token comment">#列出所有的系统服务。</span>
|
||||
<span class="token function">chkconfig</span> --add httpd <span class="token comment">#增加httpd服务。</span>
|
||||
<span class="token function">chkconfig</span> --del httpd <span class="token comment">#删除httpd服务。</span>
|
||||
<span class="token function">chkconfig</span> --level httpd <span class="token number">2345</span> on <span class="token comment">#设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态。</span>
|
||||
|
|
@ -135,7 +152,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199097"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199097"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220374"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220374"></script>
|
||||
</body>
|
||||
</html>
|
||||
52
c/chmod.html
52
c/chmod.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chmod,用来变更文件或目录的权限">
|
||||
<title>chmod 命令,Linux chmod 命令详解:用来变更文件或目录的权限 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199115">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220390">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,10 @@
|
|||
<h1 id="chmod"><a class="anchor" aria-hidden="true" tabindex="-1" href="#chmod"><span class="octicon octicon-link"></span></a>chmod</h1>
|
||||
<p>用来变更文件或目录的权限</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chmod</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. MODE<span class="token punctuation">[</span>,MODE<span class="token punctuation">]</span><span class="token punctuation">..</span>. FILE<span class="token punctuation">..</span>.
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chmod [OPTION]... MODE[,MODE]... FILE...
|
||||
chmod [OPTION]... OCTAL-MODE FILE...
|
||||
chmod [OPTION]... --reference=RFILE FILE...
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chmod</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. MODE<span class="token punctuation">[</span>,MODE<span class="token punctuation">]</span><span class="token punctuation">..</span>. FILE<span class="token punctuation">..</span>.
|
||||
<span class="token function">chmod</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. OCTAL-MODE FILE<span class="token punctuation">..</span>.
|
||||
<span class="token function">chmod</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. --reference<span class="token operator">=</span>RFILE FILE<span class="token punctuation">..</span>.
|
||||
</code></pre>
|
||||
|
|
@ -69,7 +72,16 @@
|
|||
<p>mode:八进制数或符号组合。</p>
|
||||
<p>file:指定要更改权限的一到多个文件。</p>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">-c, --changes:当文件的权限更改时输出操作信息。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c, --changes:当文件的权限更改时输出操作信息。
|
||||
--no-preserve-root:不将'/'特殊化处理,默认选项。
|
||||
--preserve-root:不能在根目录下递归操作。
|
||||
-f, --silent, --quiet:抑制多数错误消息的输出。
|
||||
-v, --verbose:无论文件是否更改了权限,一律输出操作信息。
|
||||
--reference=RFILE:使用参考文件或参考目录RFILE的权限来设置目标文件或目录的权限。
|
||||
-R, --recursive:对目录以及目录下的文件递归执行更改权限操作。
|
||||
--help:显示帮助信息并退出。
|
||||
--version:显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c, --changes:当文件的权限更改时输出操作信息。
|
||||
--no-preserve-root:不将<span class="token string">'/'</span>特殊化处理,默认选项。
|
||||
--preserve-root:不能在根目录下递归操作。
|
||||
-f, --silent, --quiet:抑制多数错误消息的输出。
|
||||
|
|
@ -100,7 +112,18 @@
|
|||
<li><code>=</code>符号代表添加目标用户相应的权限,删除未提到的权限。</li>
|
||||
</ul>
|
||||
</blockquote>
|
||||
<pre class="language-shell"><code class="language-shell">linux文件的用户权限说明:
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="linux文件的用户权限说明:
|
||||
|
||||
# 查看当前目录(包含隐藏文件)的长格式。
|
||||
ls -la
|
||||
-rw-r--r-- 1 user staff 651 Oct 12 12:53 .gitmodules
|
||||
|
||||
# 第1位如果是d则代表目录,是-则代表普通文件。
|
||||
# 更多详情请参阅info coreutils 'ls invocation'(ls命令的info文档)的'-l'选项部分。
|
||||
# 第2到4位代表当前用户的权限。
|
||||
# 第5到7位代表组用户的权限。
|
||||
# 第8到10位代表其他用户的权限。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">linux文件的用户权限说明:
|
||||
|
||||
<span class="token comment"># 查看当前目录(包含隐藏文件)的长格式。</span>
|
||||
<span class="token function">ls</span> -la
|
||||
|
|
@ -112,7 +135,22 @@
|
|||
<span class="token comment"># 第5到7位代表组用户的权限。</span>
|
||||
<span class="token comment"># 第8到10位代表其他用户的权限。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 添加组用户的写权限。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 添加组用户的写权限。
|
||||
chmod g+w ./test.log
|
||||
# 删除其他用户的所有权限。
|
||||
chmod o= ./test.log
|
||||
# 使得所有用户都没有写权限。
|
||||
chmod a-w ./test.log
|
||||
# 当前用户具有所有权限,组用户有读写权限,其他用户只有读权限。
|
||||
chmod u=rwx, g=rw, o=r ./test.log
|
||||
# 等价的八进制数表示:
|
||||
chmod 754 ./test.log
|
||||
# 将目录以及目录下的文件都设置为所有用户拥有读写权限。
|
||||
# 注意,使用'-R'选项一定要保留当前用户的执行和读取权限,否则会报错!
|
||||
chmod -R a=rw ./testdir/
|
||||
# 根据其他文件的权限设置文件权限。
|
||||
chmod --reference=./1.log ./test.log
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 添加组用户的写权限。</span>
|
||||
<span class="token function">chmod</span> g+w ./test.log
|
||||
<span class="token comment"># 删除其他用户的所有权限。</span>
|
||||
<span class="token function">chmod</span> <span class="token assign-left variable">o</span><span class="token operator">=</span> ./test.log
|
||||
|
|
@ -165,7 +203,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199116"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199116"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220390"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220390"></script>
|
||||
</body>
|
||||
</html>
|
||||
23
c/chown.html
23
c/chown.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chown,用来变更文件或目录的拥有者或所属群组">
|
||||
<title>chown 命令,Linux chown 命令详解:用来变更文件或目录的拥有者或所属群组 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199125">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220398">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,10 +58,20 @@
|
|||
<p><strong>chown命令</strong> 改变某个文件或目录的所有者和所属的组,该命令可以向某个用户授权,使该用户变成指定文件的所有者或者改变文件所属的组。用户可以是用户或者是用户D,用户组可以是组名或组id。文件名可以使由空格分开的文件列表,在文件名中可以包含通配符。</p>
|
||||
<p>只有文件主和超级用户才可以便用该命令。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chown<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chown(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chown<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-c或——changes:效果类似“-v”参数,但仅回报更改的部分;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c或——changes:效果类似“-v”参数,但仅回报更改的部分;
|
||||
-f或--quite或——silent:不显示错误信息;
|
||||
-h或--no-dereference:只对符号连接的文件作修改,而不更改其他任何相关文件;
|
||||
-R或——recursive:递归处理,将指定目录下的所有文件及子目录一并处理;
|
||||
-v或——version:显示指令执行过程;
|
||||
--dereference:效果和“-h”参数相同;
|
||||
--help:在线帮助;
|
||||
--reference=<参考文件或目录>:把指定文件或目录的拥有者与所属群组全部设成和参考文件或目录的拥有者与所属群组相同;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c或——changes:效果类似“-v”参数,但仅回报更改的部分;
|
||||
-f或--quite或——silent:不显示错误信息;
|
||||
-h或--no-dereference:只对符号连接的文件作修改,而不更改其他任何相关文件;
|
||||
-R或——recursive:递归处理,将指定目录下的所有文件及子目录一并处理;
|
||||
|
|
@ -75,7 +85,8 @@
|
|||
<p>用户:组:指定所有者和所属工作组。当省略“:组”,仅改变文件所有者;<br>文件:指定要改变所有者和工作组的文件列表。支持多个文件和目标,支持shell通配符。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将目录<code>/usr/meng</code>及其下面的所有文件、子目录的文件主改成 liu:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chown</span> -R liu /usr/meng
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chown -R liu /usr/meng
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chown</span> -R liu /usr/meng
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -102,7 +113,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199126"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199126"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220399"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220399"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chpasswd,批量更新用户口令的工具">
|
||||
<title>chpasswd 命令,Linux chpasswd 命令详解:批量更新用户口令的工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199132">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220406">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,16 +57,21 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chpasswd命令</strong> 是批量更新用户口令的工具,是把一个文件内容重新定向添加到<code>/etc/shadow</code>中。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chpasswd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chpasswd(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chpasswd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-e:输入的密码是加密后的密文;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-e:输入的密码是加密后的密文;
|
||||
-h:显示帮助信息并退出;
|
||||
-m:当被支持的密码未被加密时,使用MD5加密代替DES加密。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-e:输入的密码是加密后的密文;
|
||||
-h:显示帮助信息并退出;
|
||||
-m:当被支持的密码未被加密时,使用MD5加密代替DES加密。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>先创建用户密码对应文件,格式为<code>username:password</code>,如<code>abc:abc123</code>,必须以这种格式来书写,并且不能有空行,保存成文本文件user.txt,然后执行chpasswd命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell">chpasswd <span class="token operator"><</span> user.txt
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chpasswd < user.txt
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chpasswd <span class="token operator"><</span> user.txt
|
||||
</code></pre>
|
||||
<p>以上是运用chpasswd命令来批量修改密码。是linux系统管理中的捷径。</p>
|
||||
</div>
|
||||
|
|
@ -94,7 +99,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199132"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199132"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220406"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220406"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chroot,把根目录换成指定的目的目录">
|
||||
<title>chroot 命令,Linux chroot 命令详解:把根目录换成指定的目的目录 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199149">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220424">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -64,10 +64,13 @@
|
|||
<p><strong>切换系统的根目录位置,引导 Linux 系统启动以及急救系统等:</strong></p>
|
||||
<p>chroot 的作用就是切换系统的根位置,而这个作用最为明显的是在系统初始引导磁盘的处理过程中使用,从初始 RAM 磁盘 (initrd) 切换系统的根位置并执行真正的 init。另外,当系统出现一些问题时,我们也可以使用 chroot 来切换到一个临时的系统。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chroot<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chroot(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chroot<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--help:在线帮助;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--help:在线帮助;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--help:在线帮助;
|
||||
--version:显示版本信息。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
|
|
@ -77,7 +80,8 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p><strong>将target作为根目录(运行其中的<code>/bin/sh</code>):</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chroot</span> target /bin/sh
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chroot target /bin/sh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chroot</span> target /bin/sh
|
||||
</code></pre>
|
||||
<p>这里,target是busybox安装好的路径,类似一个文件系统包含了许多工具。这样,将会进入一个shell界面,这个shell以target为根。运行exit退出该shell又返回原来的本机环境了,也可以使用Ctrl+D。</p>
|
||||
<p>注意:</p>
|
||||
|
|
@ -86,37 +90,51 @@
|
|||
<li>如果直接chroot target默认寻找target的/bin/bash.这会以target作为根目录</li>
|
||||
</ul>
|
||||
<p>将target作为根目录(运行其中的<code>/bin/ls</code>):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chroot</span> target /bin/ls
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chroot target /bin/ls
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chroot</span> target /bin/ls
|
||||
</code></pre>
|
||||
<p>这里,target是busybox安装好的路径,类似一个文件系统包含了许多工具。这样运行的是target中的ls(不是本机的<code>/bin/ls</code>),然后返回立即本机的目录环境。</p>
|
||||
<p>注意,自己在本地编译一个程序生成a.out之后,拷进<code>target/bin/</code>中这样运行却不行,因为它包含了动态连接的库,需要用ldd查看a.out需要那些动态库,将这些库拷贝到新根的对应路径下才能执行。</p>
|
||||
<p><strong>用chroot运行自己编译的一个程序:</strong></p>
|
||||
<p>准备chroot的根目录:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">mkdir</span> newRoot
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="mkdir newRoot
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">mkdir</span> newRoot
|
||||
</code></pre>
|
||||
<p>编译自己的程序:</p>
|
||||
<pre class="language-shell"><code class="language-shell">gcc main.c
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="gcc main.c
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">gcc main.c
|
||||
</code></pre>
|
||||
<p>这里main.c生成a.out,功能是输出hello。</p>
|
||||
<p>查看程序需要的库:</p>
|
||||
<pre class="language-shell"><code class="language-shell">ldd a.out
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ldd a.out
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ldd a.out
|
||||
</code></pre>
|
||||
<p>输入之后,输出如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">linux-gate.so.1 <span class="token operator">=</span> <span class="token operator">&</span>gt<span class="token punctuation">;</span> <span class="token punctuation">(</span>0xb8034000<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="linux-gate.so.1 = &gt; (0xb8034000)
|
||||
libc.so.6 = &gt; /lib/tls/i686/cmov/libc.so.6 (0xb7eab000)
|
||||
/lib/ld-linux.so.2 (0xb801a000)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">linux-gate.so.1 <span class="token operator">=</span> <span class="token operator">&</span>gt<span class="token punctuation">;</span> <span class="token punctuation">(</span>0xb8034000<span class="token punctuation">)</span>
|
||||
libc.so.6 <span class="token operator">=</span> <span class="token operator">&</span>gt<span class="token punctuation">;</span> /lib/tls/i686/cmov/libc.so.6 <span class="token punctuation">(</span>0xb7eab000<span class="token punctuation">)</span>
|
||||
/lib/ld-linux.so.2 <span class="token punctuation">(</span>0xb801a000<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<p>将程序需要的库和程序拷贝到新根目录下:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> a.out newRoot
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp a.out newRoot
|
||||
mkdir newRoot/lib
|
||||
cp /lib/tls/i686/cmov/libc.so.6 newRoot/lib
|
||||
cp /lib/ld-linux.so.2 newRoot/lib
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> a.out newRoot
|
||||
<span class="token function">mkdir</span> newRoot/lib
|
||||
<span class="token function">cp</span> /lib/tls/i686/cmov/libc.so.6 newRoot/lib
|
||||
<span class="token function">cp</span> /lib/ld-linux.so.2 newRoot/lib
|
||||
</code></pre>
|
||||
<p>这里newRoot内容将如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">a.out lib/
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="a.out lib/
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">a.out lib/
|
||||
</code></pre>
|
||||
<p>使用chroot运行自己的程序:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">su</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="su
|
||||
chroot newRoot /a.out
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">su</span>
|
||||
<span class="token function">chroot</span> newRoot /a.out
|
||||
</code></pre>
|
||||
<p>这样就能够正确运行a.out了,因为a.out使用到了其他的动态连接库,所以需要将库拷贝到newRoot中,如果没有其他库那么直接拷贝a.out就能运行。例如静态编译后的busybox,其安装目录中的<code>/bin/busybox</code>就没有依赖其他库。</p>
|
||||
|
|
@ -145,7 +163,7 @@ libc.so.6 <span class="token operator">=</span> <span class="token operator">&#x
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199150"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199150"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220424"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220424"></script>
|
||||
</body>
|
||||
</html>
|
||||
50
c/chsh.html
50
c/chsh.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,chsh,用来更换登录系统时使用的shell">
|
||||
<title>chsh 命令,Linux chsh 命令详解:用来更换登录系统时使用的shell - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199167">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220437">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>chsh命令</strong> 用来更换登录系统时使用的shell。若不指定任何参数与用户名称,则chsh会以应答的方式进行设置。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">chsh<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chsh(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">chsh<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-s<span class="token operator"><</span>shell 名称<span class="token operator">></span>或--shell<span class="token operator"><</span>shell 名称<span class="token operator">></span>:更改系统预设的shell环境。;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-s<shell 名称>或--shell<shell 名称>:更改系统预设的shell环境。;
|
||||
-l或--list-shells:列出目前系统可用的shell清单;
|
||||
-u或--help:在线帮助;
|
||||
-v或-version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-s<span class="token operator"><</span>shell 名称<span class="token operator">></span>或--shell<span class="token operator"><</span>shell 名称<span class="token operator">></span>:更改系统预设的shell环境。;
|
||||
-l或--list-shells:列出目前系统可用的shell清单;
|
||||
-u或--help:在线帮助;
|
||||
-v或-version:显示版本信息。
|
||||
|
|
@ -70,14 +75,24 @@
|
|||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p><strong>查看系统安装了哪些shell的两种方法:</strong></p>
|
||||
<p>第一种:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -l
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ chsh -l
|
||||
/bin/sh
|
||||
/bin/bash
|
||||
/sbin/nologin
|
||||
/bin/zsh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -l
|
||||
/bin/sh
|
||||
/bin/bash
|
||||
/sbin/nologin
|
||||
/bin/zsh
|
||||
</code></pre>
|
||||
<p>第二种:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token function">cat</span> /etc/shells
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ cat /etc/shells
|
||||
/bin/sh
|
||||
/bin/bash
|
||||
/sbin/nologin
|
||||
/bin/zsh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token function">cat</span> /etc/shells
|
||||
/bin/sh
|
||||
/bin/bash
|
||||
/sbin/nologin
|
||||
|
|
@ -85,24 +100,37 @@
|
|||
</code></pre>
|
||||
<p>其实<code>chsh -l</code>也是来查看这个文件。</p>
|
||||
<p><strong>查看当前正在使用的shell:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token builtin class-name">echo</span> <span class="token environment constant">$SHELL</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ echo $SHELL
|
||||
/bin/bash
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token builtin class-name">echo</span> <span class="token environment constant">$SHELL</span>
|
||||
/bin/bash
|
||||
</code></pre>
|
||||
<p>注意SHELL一定要是大写。可以看到,目前使用的shell是<code>/bin/bash</code></p>
|
||||
<p><strong>把我的shell改成zsh:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -s /bin/zsh
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ chsh -s /bin/zsh
|
||||
Changing shell for rocrocket.
|
||||
Password:
|
||||
Shell changed.
|
||||
[rocrocket@localhost ~]$
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -s /bin/zsh
|
||||
Changing shell <span class="token keyword">for</span> rocrocket.
|
||||
Password:
|
||||
Shell changed.
|
||||
<span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$
|
||||
</code></pre>
|
||||
<p>使用chsh加选项<code>-s</code>就可以修改登录的shell了!你会发现你现在执行<code>echo $SHELL</code>后仍然输出为<code>/bin/bash</code>,这是因为你需要重启你的shell才完全投入到zsh怀抱中去。<code>chsh -s</code>其实修改的就是<code>/etc/passwd</code>文件里和你的用户名相对应的那一行。现在来查看下:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token function">cat</span> /etc/passwd<span class="token operator">|</span><span class="token function">grep</span> ^rocrocket
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ cat /etc/passwd|grep ^rocrocket
|
||||
rocrocket:x:500:500:rocrocket,China:/rocrocket/PSB/home:/bin/zsh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ <span class="token function">cat</span> /etc/passwd<span class="token operator">|</span><span class="token function">grep</span> ^rocrocket
|
||||
rocrocket:x:500:500:rocrocket,China:/rocrocket/PSB/home:/bin/zsh
|
||||
</code></pre>
|
||||
<p>你可以发现输出内容的最后部分已经变成了<code>/bin/zsh</code>了,下次重启的时候,linux就会读取这一命令来启动shell了!</p>
|
||||
<p><strong>把shell修改回/bin/bash:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -s /bin/bash
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[rocrocket@localhost ~]$ chsh -s /bin/bash
|
||||
Changing shell for rocrocket.
|
||||
Password:
|
||||
Shell changed.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>rocrocket@localhost ~<span class="token punctuation">]</span>$ chsh -s /bin/bash
|
||||
Changing shell <span class="token keyword">for</span> rocrocket.
|
||||
Password:
|
||||
Shell changed.
|
||||
|
|
@ -132,7 +160,7 @@ Shell changed.
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199168"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199168"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220438"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220438"></script>
|
||||
</body>
|
||||
</html>
|
||||
19
c/cksum.html
19
c/cksum.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cksum,检查文件的CRC是否正确">
|
||||
<title>cksum 命令,Linux cksum 命令详解:检查文件的CRC是否正确 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199175">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220445">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -59,20 +59,25 @@
|
|||
<p>注意:CRC是指一种排错检查方法,即循环冗余校验法。</p>
|
||||
<p>指定文件交由cksum命令进行校验后,会返回校验结果供用户核对文件是否正确无误。若不指定任何文件名称或是所给予的文件名为"-",则cksum命令会从标准输入设备中读取数据。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cksum<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cksum(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cksum<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--help:在线帮助;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--help:在线帮助;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--help:在线帮助;
|
||||
--version:显示版本信息。
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>文件:指定要计算校验的版本信息。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>使用cksum命令计算文件"testfile1"的完整性,输入如下命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cksum</span> testfile1 <span class="token comment">#对指定文件进行CRC校验</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cksum testfile1 #对指定文件进行CRC校验
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cksum</span> testfile1 <span class="token comment">#对指定文件进行CRC校验</span>
|
||||
</code></pre>
|
||||
<p>以上命令执行后,将输出校验码等相关的信息,具体输出信息如下所示:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">1263453430</span> <span class="token number">78</span> testfile1 <span class="token comment">#输出信息</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="1263453430 78 testfile1 #输出信息
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">1263453430</span> <span class="token number">78</span> testfile1 <span class="token comment">#输出信息</span>
|
||||
</code></pre>
|
||||
<p>上面的输出信息中,"1263453430"表示校验码,"78"表示字节数。</p>
|
||||
<p>注意:如果文件中有任何字符被修改,都将改变计算后CRC校验码的值。</p>
|
||||
|
|
@ -101,7 +106,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199176"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199176"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220445"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220445"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,clear,清除当前屏幕终端上的任何信息">
|
||||
<title>clear 命令,Linux clear 命令详解:清除当前屏幕终端上的任何信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199181">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220450">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>clear命令</strong> 用于清除当前屏幕终端上的任何信息。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">clear</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="clear
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">clear</span>
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>直接输入clear命令当前终端上的任何信息就可被清除。</p>
|
||||
|
|
@ -86,7 +87,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199181"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199181"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220450"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220450"></script>
|
||||
</body>
|
||||
</html>
|
||||
30
c/clock.html
30
c/clock.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,clock,用于调整 RTC 时间">
|
||||
<title>clock 命令,Linux clock 命令详解:用于调整 RTC 时间 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199189">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220459">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,11 +57,25 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>clock命令</strong>用于调整 RTC 时间。 RTC 是电脑内建的硬件时间,执行这项指令可以显示现在时刻,调整硬件时钟的时间,将系统时间设成与硬件时钟之时间一致,或是把系统时间回存到硬件时钟。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">clock <span class="token punctuation">[</span>--adjust<span class="token punctuation">]</span><span class="token punctuation">[</span>--debug<span class="token punctuation">]</span><span class="token punctuation">[</span>--directisa<span class="token punctuation">]</span><span class="token punctuation">[</span>--getepoch<span class="token punctuation">]</span><span class="token punctuation">[</span>--hctosys<span class="token punctuation">]</span><span class="token punctuation">[</span>--set --date<span class="token operator">=</span><span class="token string">"<日期时间>"</span><span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="clock [--adjust][--debug][--directisa][--getepoch][--hctosys][--set --date="<日期时间>"]
|
||||
[--setepoch --epoch=< >][--show][--systohc][--test][--utc][--version]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">clock <span class="token punctuation">[</span>--adjust<span class="token punctuation">]</span><span class="token punctuation">[</span>--debug<span class="token punctuation">]</span><span class="token punctuation">[</span>--directisa<span class="token punctuation">]</span><span class="token punctuation">[</span>--getepoch<span class="token punctuation">]</span><span class="token punctuation">[</span>--hctosys<span class="token punctuation">]</span><span class="token punctuation">[</span>--set --date<span class="token operator">=</span><span class="token string">"<日期时间>"</span><span class="token punctuation">]</span>
|
||||
<span class="token punctuation">[</span>--setepoch --epoch<span class="token operator">=</span><span class="token operator"><</span> <span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>--show<span class="token punctuation">]</span><span class="token punctuation">[</span>--systohc<span class="token punctuation">]</span><span class="token punctuation">[</span>--test<span class="token punctuation">]</span><span class="token punctuation">[</span>--utc<span class="token punctuation">]</span><span class="token punctuation">[</span>--version<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--adjust 第一次使用<span class="token string">"--set"</span>或<span class="token string">"--systohc"</span>参数设置硬件时钟,会在/etc目录下产生一个名称为adjtime的文件。当再次使用这两个参数调整硬件时钟,此文件便会记录两次调整间之差异,日后执行clock指令加上<span class="token string">"--adjust"</span>参数时,程序会自动根 据记录文件的数值差异,计算出平均值,自动调整硬件时钟的时间。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--adjust 第一次使用"--set"或"--systohc"参数设置硬件时钟,会在/etc目录下产生一个名称为adjtime的文件。当再次使用这两个参数调整硬件时钟,此文件便会记录两次调整间之差异,日后执行clock指令加上"--adjust"参数时,程序会自动根 据记录文件的数值差异,计算出平均值,自动调整硬件时钟的时间。
|
||||
--debug 详细显示指令执行过程,便于排错或了解程序执行的情形。
|
||||
--directisa 告诉clock指令不要通过/dev/rtc设备文件,直接对硬件时钟进行存取。这个参数适用于仅有ISA总线结构的老式电脑。
|
||||
--getepoch 把系统核心内的硬件时钟新时代数值,呈现到标准输出设备。
|
||||
--hctosys Hardware Clock to System Time,把系统时间设成和硬件时钟一致。由于这个动作将会造成系统全面更新文件的存取时间,所以最好在系统启动时就执行它。
|
||||
--set--date 设置硬件时钟的日期和时间。
|
||||
--setepoch--epoch=<年份> 设置系统核心之硬件时钟的新时代数值,年份以四位树字表示。
|
||||
--show 读取硬件时钟的时间,并将其呈现至标准输出设备。
|
||||
--systohc System Time to Hardware Clock,将系统时间存回硬件时钟内。
|
||||
--test 仅作测试,并不真的将时间写入硬件时钟或系统时间。
|
||||
--utc 把硬件时钟上的时间时为CUT,有时也称为UTC或UCT。
|
||||
--version 显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--adjust 第一次使用<span class="token string">"--set"</span>或<span class="token string">"--systohc"</span>参数设置硬件时钟,会在/etc目录下产生一个名称为adjtime的文件。当再次使用这两个参数调整硬件时钟,此文件便会记录两次调整间之差异,日后执行clock指令加上<span class="token string">"--adjust"</span>参数时,程序会自动根 据记录文件的数值差异,计算出平均值,自动调整硬件时钟的时间。
|
||||
--debug 详细显示指令执行过程,便于排错或了解程序执行的情形。
|
||||
--directisa 告诉clock指令不要通过/dev/rtc设备文件,直接对硬件时钟进行存取。这个参数适用于仅有ISA总线结构的老式电脑。
|
||||
--getepoch 把系统核心内的硬件时钟新时代数值,呈现到标准输出设备。
|
||||
|
|
@ -76,10 +90,12 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>获取当前的时间</p>
|
||||
<pre class="language-shell"><code class="language-shell">clock <span class="token comment"># 获取当前的时间</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="clock # 获取当前的时间
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">clock <span class="token comment"># 获取当前的时间</span>
|
||||
</code></pre>
|
||||
<p>显示UTC时间</p>
|
||||
<pre class="language-shell"><code class="language-shell">clock -utc <span class="token comment">#显示UTC时间</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="clock -utc #显示UTC时间
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">clock -utc <span class="token comment">#显示UTC时间</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -106,7 +122,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199190"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199190"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220459"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220459"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,clockdiff,检测两台linux主机的时间差">
|
||||
<title>clockdiff 命令,Linux clockdiff 命令详解:检测两台linux主机的时间差 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199204">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220474">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,11 +57,25 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p>在ip报文的首部和ICMP报文的首部都可以放入时间戳数据。 <strong>clockdiff</strong> 程序正是使用时间戳来测算目的主机和本地主机的系统时间差。</p>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-o:使用IP时间戳选项来测量系统时间差。时间戳只用3个。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-o:使用IP时间戳选项来测量系统时间差。时间戳只用3个。
|
||||
-o1:使用IP时间戳选项来测量系统时间差。用4个时间戳。如果-o和-o1都没有设置,那么就是用ICMP时间戳来测试系统时间差。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-o:使用IP时间戳选项来测量系统时间差。时间戳只用3个。
|
||||
-o1:使用IP时间戳选项来测量系统时间差。用4个时间戳。如果-o和-o1都没有设置,那么就是用ICMP时间戳来测试系统时间差。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">lixi@lixi-desktop:~$ <span class="token function">ping</span> -T tsandaddr www.ustc.edu.cn -c <span class="token number">1</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="lixi@lixi-desktop:~$ ping -T tsandaddr www.ustc.edu.cn -c 1
|
||||
PING www.ustc.edu.cn (202.38.64.9) 56(124) bytes of data.
|
||||
64 bytes from 202.38.64.9: icmp_seq=1 ttl=62 time=0.823 ms
|
||||
TS: lixi-desktop.local (210.45.74.25) 12522473 absolute
|
||||
210.45.74.1 -251
|
||||
local-gw.ustc.edu.cn (202.38.64.126) 248
|
||||
202.38.64.9 -857514
|
||||
Unrecorded hops: 3
|
||||
|
||||
--- www.ustc.edu.cn ping statistics ---
|
||||
1 packets transmitted, 1 received, 0% packet loss, time 0ms
|
||||
rtt min/avg/max/mdev = 0.823/0.823/0.823/0.000 ms
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">lixi@lixi-desktop:~$ <span class="token function">ping</span> -T tsandaddr www.ustc.edu.cn -c <span class="token number">1</span>
|
||||
PING www.ustc.edu.cn <span class="token punctuation">(</span><span class="token number">202.38</span>.64.9<span class="token punctuation">)</span> <span class="token number">56</span><span class="token punctuation">(</span><span class="token number">124</span><span class="token punctuation">)</span> bytes of data.
|
||||
<span class="token number">64</span> bytes from <span class="token number">202.38</span>.64.9: <span class="token assign-left variable">icmp_seq</span><span class="token operator">=</span><span class="token number">1</span> <span class="token assign-left variable">ttl</span><span class="token operator">=</span><span class="token number">62</span> <span class="token assign-left variable">time</span><span class="token operator">=</span><span class="token number">0.823</span> ms
|
||||
TS: lixi-desktop.local <span class="token punctuation">(</span><span class="token number">210.45</span>.74.25<span class="token punctuation">)</span> <span class="token number">12522473</span> absolute
|
||||
|
|
@ -75,16 +89,25 @@ Unrecorded hops: <span class="token number">3</span>
|
|||
rtt min/avg/max/mdev <span class="token operator">=</span> <span class="token number">0.823</span>/0.823/0.823/0.000 ms
|
||||
</code></pre>
|
||||
<p>首先由上面的得出在RRT不大的时候,几个ICMP时间戳的关系。本地主机和202.38.64.9之间的时间差约为:-857514+248-251=-857517。分别用-o(IP选项中时间戳)和不带选项(ICMP路由时间戳)上述路由的系统时间进行测试。得到的结果:</p>
|
||||
<pre class="language-shell"><code class="language-shell">lixi@lixi-desktop:~<span class="token comment"># ./clockdiff -o 202.38.64.9 </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="lixi@lixi-desktop:~# ./clockdiff -o 202.38.64.9
|
||||
..................................................
|
||||
host=202.38.64.9 rtt=1(0)ms/1ms delta=-857517ms/-857517ms Wed Dec 17 11:28:30 2008
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">lixi@lixi-desktop:~<span class="token comment"># ./clockdiff -o 202.38.64.9 </span>
|
||||
<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
|
||||
<span class="token assign-left variable">host</span><span class="token operator">=</span><span class="token number">202.38</span>.64.9 <span class="token assign-left variable">rtt</span><span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span>ms/1ms <span class="token assign-left variable">delta</span><span class="token operator">=</span>-857517ms/-857517ms Wed Dec <span class="token number">17</span> <span class="token number">11</span>:28:30 <span class="token number">2008</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell">lixi@lixi-desktop:~<span class="token comment"># ./clockdiff 202.38.64.9</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="lixi@lixi-desktop:~# ./clockdiff 202.38.64.9
|
||||
.
|
||||
host=202.38.64.9 rtt=750(187)ms/0ms delta=-857517ms/-857517ms Wed Dec 17 11:28:35 2008
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">lixi@lixi-desktop:~<span class="token comment"># ./clockdiff 202.38.64.9</span>
|
||||
<span class="token builtin class-name">.</span>
|
||||
<span class="token assign-left variable">host</span><span class="token operator">=</span><span class="token number">202.38</span>.64.9 <span class="token assign-left variable">rtt</span><span class="token operator">=</span><span class="token number">750</span><span class="token punctuation">(</span><span class="token number">187</span><span class="token punctuation">)</span>ms/0ms <span class="token assign-left variable">delta</span><span class="token operator">=</span>-857517ms/-857517ms Wed Dec <span class="token number">17</span> <span class="token number">11</span>:28:35 <span class="token number">2008</span>
|
||||
</code></pre>
|
||||
<p>两种方法测试的都比较准确。</p>
|
||||
<pre class="language-shell"><code class="language-shell">lixi@lixi-desktop:~<span class="token comment">#./clockdiff gigagate1.Princeton.EDU</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="lixi@lixi-desktop:~#./clockdiff gigagate1.Princeton.EDU
|
||||
..................................................
|
||||
host=gigagate1.Princeton.EDU rtt=307(21)ms/271ms delta=-5ms/-5ms Wed Dec 17 11:50:16 2008
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">lixi@lixi-desktop:~<span class="token comment">#./clockdiff gigagate1.Princeton.EDU</span>
|
||||
<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
|
||||
<span class="token assign-left variable">host</span><span class="token operator">=</span>gigagate1.Princeton.EDU <span class="token assign-left variable">rtt</span><span class="token operator">=</span><span class="token number">307</span><span class="token punctuation">(</span><span class="token number">21</span><span class="token punctuation">)</span>ms/271ms <span class="token assign-left variable">delta</span><span class="token operator">=</span>-5ms/-5ms Wed Dec <span class="token number">17</span> <span class="token number">11</span>:50:16 <span class="token number">2008</span>
|
||||
</code></pre>
|
||||
|
|
@ -114,7 +137,7 @@ rtt min/avg/max/mdev <span class="token operator">=</span> <span class="token nu
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199205"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199205"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220475"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220475"></script>
|
||||
</body>
|
||||
</html>
|
||||
35
c/cmp.html
35
c/cmp.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cmp,比较两个文件是否有差异">
|
||||
<title>cmp 命令,Linux cmp 命令详解:比较两个文件是否有差异 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199214">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220483">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cmp命令</strong> 用来比较两个文件是否有差异。当相互比较的两个文件完全一样时,则该指令不会显示任何信息。若发现有差异,预设会标示出第一个不通之处的字符和列数编号。若不指定任何文件名称或是所给予的文件名为“-”,则cmp指令会从标准输入设备读取数据。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cmp<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cmp(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cmp<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-c或--print-chars:除了标明差异处的十进制字码之外,一并显示该字符所对应字符;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c或--print-chars:除了标明差异处的十进制字码之外,一并显示该字符所对应字符;
|
||||
-i<字符数目>或--ignore-initial=<字符数目>:指定一个数目;
|
||||
-l或——verbose:标示出所有不一样的地方;
|
||||
-s或--quiet或——silent:不显示错误信息;
|
||||
-v或——version:显示版本信息;
|
||||
--help:在线帮助。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c或--print-chars:除了标明差异处的十进制字码之外,一并显示该字符所对应字符;
|
||||
-i<span class="token operator"><</span>字符数目<span class="token operator">></span>或--ignore-initial<span class="token operator">=</span><span class="token operator"><</span>字符数目<span class="token operator">></span>:指定一个数目;
|
||||
-l或——verbose:标示出所有不一样的地方;
|
||||
-s或--quiet或——silent:不显示错误信息;
|
||||
|
|
@ -71,10 +78,20 @@
|
|||
<p>目录:比较两个文件的差异。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>使用cmp命令比较文件"testfile"和文件"testfile1"两个文件,则输入下面的命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cmp</span> testfile testfile1 <span class="token comment">#比较两个指定的文件</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cmp testfile testfile1 #比较两个指定的文件
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cmp</span> testfile testfile1 <span class="token comment">#比较两个指定的文件</span>
|
||||
</code></pre>
|
||||
<p>在上述指令执行之前,使用cat命令查看两个指定的文件内容,如下所示:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> testfile <span class="token comment">#查看文件内容 </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat testfile #查看文件内容
|
||||
Absncn 50 #显示文件“testfile”
|
||||
Asldssja 60
|
||||
Jslkadjls 85
|
||||
|
||||
cat testfile1 #查看文件内容
|
||||
Absncn 50 #显示文件“testfile1”
|
||||
AsldssjE 62
|
||||
Jslkadjls 85
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> testfile <span class="token comment">#查看文件内容 </span>
|
||||
Absncn <span class="token number">50</span> <span class="token comment">#显示文件“testfile” </span>
|
||||
Asldssja <span class="token number">60</span>
|
||||
Jslkadjls <span class="token number">85</span>
|
||||
|
|
@ -85,7 +102,9 @@ AsldssjE <span class="token number">62</span>
|
|||
Jslkadjls <span class="token number">85</span>
|
||||
</code></pre>
|
||||
<p>然后,再执行cmp命令,并返回比较结果,具体如下所示:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cmp</span> testfile testfile1 <span class="token comment">#比较两个文件 </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cmp testfile testfile1 #比较两个文件
|
||||
testfile testfile1 #有差异:第8字节,第2行
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cmp</span> testfile testfile1 <span class="token comment">#比较两个文件 </span>
|
||||
testfile testfile1 <span class="token comment">#有差异:第8字节,第2行 </span>
|
||||
</code></pre>
|
||||
<p>注意:在比较结果中,只能够显示第一比较结果。</p>
|
||||
|
|
@ -114,7 +133,7 @@ testfile testfile1 <span class="token comment">#有差异:第8字节
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199214"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199214"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220483"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220483"></script>
|
||||
</body>
|
||||
</html>
|
||||
15
c/col.html
15
c/col.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,col,过滤控制字符">
|
||||
<title>col 命令,Linux col 命令详解:过滤控制字符 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199219">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220488">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>col命令</strong> 是一个标准输入文本过滤器,它从标注输入设备读取文本内容,并把内容显示到标注输出设备。在许多UNIX说明文件里,都有RLF控制字符。当我们运用shell特殊字符<code>></code>和<code>>></code>,把说明文件的内容输出成纯文本文件时,控制字符会变成乱码,col命令则能有效滤除这些控制字符。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">col<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="col(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">col<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b:过滤掉所有的控制字符,包括RLF和HRLF;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b:过滤掉所有的控制字符,包括RLF和HRLF;
|
||||
-f:滤掉RLF字符,但允许将HRLF字符呈现出来;
|
||||
-x:以多个空格字符来表示跳格字符;
|
||||
-l<缓冲区列数>:预设的内存缓冲区有128列,用户可以自行指定缓冲区的大小。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b:过滤掉所有的控制字符,包括RLF和HRLF;
|
||||
-f:滤掉RLF字符,但允许将HRLF字符呈现出来;
|
||||
-x:以多个空格字符来表示跳格字符;
|
||||
-l<span class="token operator"><</span>缓冲区列数<span class="token operator">></span>:预设的内存缓冲区有128列,用户可以自行指定缓冲区的大小。
|
||||
|
|
@ -90,7 +95,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199220"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199220"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220489"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220489"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,colrm,删除文件中的指定列">
|
||||
<title>colrm 命令,Linux colrm 命令详解:删除文件中的指定列 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199224">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220493">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>colrm命令</strong> 用于删除文件中的指定列。colrm命令从标准输入设备读取书记,转而输出到标准输出设备。如果不加任何参数,则colrm命令不会过滤任何一行。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">colrm<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="colrm(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">colrm<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<ul>
|
||||
|
|
@ -89,7 +90,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199225"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199225"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220495"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220495"></script>
|
||||
</body>
|
||||
</html>
|
||||
91
c/comm.html
91
c/comm.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,comm,按行比较两个已排序的文件。">
|
||||
<title>comm 命令,Linux comm 命令详解:按行比较两个已排序的文件。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199243">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220509">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="comm"><a class="anchor" aria-hidden="true" tabindex="-1" href="#comm"><span class="octicon octicon-link"></span></a>comm</h1>
|
||||
<p>按行比较两个已排序的文件。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">comm</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. FILE1 FILE2
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="comm [OPTION]... FILE1 FILE2
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">comm</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. FILE1 FILE2
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -64,7 +65,17 @@
|
|||
<li>无选项时输出三列,第一列为<code>FILE1</code>独有的行,第二列为<code>FILE2</code>独有的行,第三列为<code>FILE1</code>,<code>FILE2</code>共有的行。</li>
|
||||
</ul>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">-1 不输出第一列。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-1 不输出第一列。
|
||||
-2 不输出第二列。
|
||||
-3 不输出第三列。
|
||||
--check-order 检查输入行是否正确的排序,即使它们确实是已排序过的。
|
||||
--nocheck-order 不检查输入行是否正确的排序。
|
||||
--output-delimiter=STR 使用STR作为输出列之间的分隔符而不是默认的TAB。
|
||||
--total 额外地增加第四列输出概要。
|
||||
-z, --zero-terminated 设置行终止符为NUL(空),而不是换行符。
|
||||
--help 显示帮助信息并退出。
|
||||
--version 显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-1 不输出第一列。
|
||||
-2 不输出第二列。
|
||||
-3 不输出第三列。
|
||||
--check-order 检查输入行是否正确的排序,即使它们确实是已排序过的。
|
||||
|
|
@ -79,7 +90,15 @@
|
|||
<p>返回0表示成功,返回非0值表示失败。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<p>文本 <code>aaa.txt</code> 内容</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat aaa.txt </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cat aaa.txt
|
||||
aaa
|
||||
bbb
|
||||
ccc
|
||||
ddd
|
||||
eee
|
||||
111
|
||||
222
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat aaa.txt </span>
|
||||
aaa
|
||||
bbb
|
||||
ccc
|
||||
|
|
@ -89,7 +108,14 @@ eee
|
|||
<span class="token number">222</span>
|
||||
</code></pre>
|
||||
<p>文本 <code>bbb.txt</code> 内容</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat bbb.txt </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cat bbb.txt
|
||||
bbb
|
||||
ccc
|
||||
aaa
|
||||
hhh
|
||||
ttt
|
||||
jjj
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat bbb.txt </span>
|
||||
bbb
|
||||
ccc
|
||||
aaa
|
||||
|
|
@ -98,7 +124,19 @@ ttt
|
|||
jjj
|
||||
</code></pre>
|
||||
<p>比较结果</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm --nocheck-order aaa.txt bbb.txt </span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# comm --nocheck-order aaa.txt bbb.txt
|
||||
aaa
|
||||
bbb
|
||||
ccc
|
||||
aaa
|
||||
ddd
|
||||
eee
|
||||
111
|
||||
222
|
||||
hhh
|
||||
ttt
|
||||
jjj
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm --nocheck-order aaa.txt bbb.txt </span>
|
||||
aaa
|
||||
bbb
|
||||
ccc
|
||||
|
|
@ -114,11 +152,24 @@ eee
|
|||
<p>输出的第一列只包含在aaa.txt中出现的行,第二列包含在bbb.txt中出现的行,第三列包含在aaa.txt和bbb.txt中相同的行。各列之间以制表符(\t)作为分隔符。</p>
|
||||
<h3 id="比较排序过的文档"><a class="anchor" aria-hidden="true" tabindex="-1" href="#比较排序过的文档"><span class="octicon octicon-link"></span></a>比较排序过的文档</h3>
|
||||
<p>先通过 sort 将文件内容排序:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># sort aaa.txt > aaa1.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# sort aaa.txt > aaa1.txt
|
||||
[root@localhost ~]# sort bbb.txt > bbb1.txt
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># sort aaa.txt > aaa1.txt</span>
|
||||
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># sort bbb.txt > bbb1.txt</span>
|
||||
</code></pre>
|
||||
<p>比较结果:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># comm aaa1.txt bbb1.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# comm aaa1.txt bbb1.txt
|
||||
111
|
||||
222
|
||||
aaa
|
||||
bbb
|
||||
ccc
|
||||
ddd
|
||||
eee
|
||||
hhh
|
||||
jjj
|
||||
ttt
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># comm aaa1.txt bbb1.txt</span>
|
||||
<span class="token number">111</span>
|
||||
<span class="token number">222</span>
|
||||
aaa
|
||||
|
|
@ -132,14 +183,23 @@ eee
|
|||
</code></pre>
|
||||
<h3 id="交集"><a class="anchor" aria-hidden="true" tabindex="-1" href="#交集"><span class="octicon octicon-link"></span></a>交集</h3>
|
||||
<p>打印两个文件的交集,需要删除第一列和第二列:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -1 -2</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# comm aaa.txt bbb.txt -1 -2
|
||||
bbb
|
||||
ccc
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -1 -2</span>
|
||||
bbb
|
||||
ccc
|
||||
</code></pre>
|
||||
<h3 id="差集"><a class="anchor" aria-hidden="true" tabindex="-1" href="#差集"><span class="octicon octicon-link"></span></a>差集</h3>
|
||||
<p>通过删除不需要的列,可以得到aaa.txt和bbb.txt的差集:</p>
|
||||
<p>aaa.txt的差集</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -2 -3</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# comm aaa.txt bbb.txt -2 -3
|
||||
aaa
|
||||
ddd
|
||||
eee
|
||||
111
|
||||
222
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -2 -3</span>
|
||||
aaa
|
||||
ddd
|
||||
eee
|
||||
|
|
@ -147,7 +207,12 @@ eee
|
|||
<span class="token number">222</span>
|
||||
</code></pre>
|
||||
<p>bbb.txt的差集</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -1 -3</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# comm aaa.txt bbb.txt -1 -3
|
||||
aaa
|
||||
hhh
|
||||
ttt
|
||||
jjj
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># comm aaa.txt bbb.txt -1 -3</span>
|
||||
aaa
|
||||
hhh
|
||||
ttt
|
||||
|
|
@ -182,7 +247,7 @@ jjj
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199243"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199243"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220510"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220510"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,command,调用并执行指定的命令">
|
||||
<title>command 命令,Linux command 命令详解:调用并执行指定的命令 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199249">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220515">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,16 +57,19 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>command命令</strong> 调用指定的指令并执行,命令执行时不查询shell函数。command命令只能够执行shell内部的命令。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">command<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="command(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">command<span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>指令:需要调用的指令及参数。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>使用command命令调用执行<code>echo Linux</code>,输入如下命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">command</span> <span class="token builtin class-name">echo</span> Linux <span class="token comment">#调用执行shell内部指令</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="command echo Linux #调用执行shell内部指令
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">command</span> <span class="token builtin class-name">echo</span> Linux <span class="token comment">#调用执行shell内部指令</span>
|
||||
</code></pre>
|
||||
<p>上面的命令执行后,将调用执行命令<code>echo Linux</code>,其执行结果如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">Linux
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="Linux
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">Linux
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -93,7 +96,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199250"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199250"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220516"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220516"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,compress,使用Lempress-Ziv编码压缩数据文件">
|
||||
<title>compress 命令,Linux compress 命令详解:使用Lempress-Ziv编码压缩数据文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199259">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220527">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,18 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>compress命令</strong> 使用“Lempress-Ziv”编码压缩数据文件。compress是个历史悠久的压缩程序,文件经它压缩后,其名称后面会多出".Z"的扩展名。当要解压缩时,可执行uncompress指令。事实上uncompress是指向compress的符号连接,因此不论是压缩或解压缩,都可通过compress指令单独完成。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">compress<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="compress(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">compress<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-f:不提示用户,强制覆盖掉目标文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f:不提示用户,强制覆盖掉目标文件;
|
||||
-c:将结果送到标准输出,无文件被改变;
|
||||
-r:递归的操作方式;
|
||||
-b<压缩效率>:压缩效率是一个介于9~16的数值,预设值为"16",指定愈大的数值,压缩效率就愈高;
|
||||
-d:对文件进行解压缩而非压缩;
|
||||
-v:显示指令执行过程;
|
||||
-V:显示指令版本及程序预设值。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f:不提示用户,强制覆盖掉目标文件;
|
||||
-c:将结果送到标准输出,无文件被改变;
|
||||
-r:递归的操作方式;
|
||||
-b<span class="token operator"><</span>压缩效率<span class="token operator">></span>:压缩效率是一个介于9~16的数值,预设值为<span class="token string">"16"</span>,指定愈大的数值,压缩效率就愈高;
|
||||
|
|
@ -72,21 +80,31 @@
|
|||
<p>文件:指定要压缩的文件列表。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将<code>/etc/man.config</code>复到<code>/tmp</code> ,并加以压缩</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cd /tmp</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# cd /tmp
|
||||
[root@localhost tmp]# cp /etc/man.config .
|
||||
[root@localhost tmp]# compress man.config
|
||||
[root@localhost tmp]# ls -l
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># cd /tmp</span>
|
||||
<span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># cp /etc/man.config .</span>
|
||||
<span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># compress man.config</span>
|
||||
<span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># ls -l</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell">-rw-r--r-- <span class="token number">1</span> root root <span class="token number">2605</span> Jul <span class="token number">27</span> <span class="token number">11</span>:43 man.config.Z
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-rw-r--r-- 1 root root 2605 Jul 27 11:43 man.config.Z
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-rw-r--r-- <span class="token number">1</span> root root <span class="token number">2605</span> Jul <span class="token number">27</span> <span class="token number">11</span>:43 man.config.Z
|
||||
</code></pre>
|
||||
<p>将刚刚的压缩档解开</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># compress -d man.config.Z</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost tmp]# compress -d man.config.Z
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># compress -d man.config.Z</span>
|
||||
</code></pre>
|
||||
<p>将 man.config 压缩成另外一个文件来备份</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># compress -c man.config > man.config.back.Z</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost tmp]# compress -c man.config > man.config.back.Z
|
||||
[root@localhost tmp]# ll man.config*
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># compress -c man.config > man.config.back.Z</span>
|
||||
<span class="token punctuation">[</span>root@localhost tmp<span class="token punctuation">]</span><span class="token comment"># ll man.config*</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell">-rw-r--r-- <span class="token number">1</span> root root <span class="token number">4506</span> Jul <span class="token number">27</span> <span class="token number">11</span>:43 man.config
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-rw-r--r-- 1 root root 4506 Jul 27 11:43 man.config
|
||||
-rw-r--r-- 1 root root 2605 Jul 27 11:46 man.config.back.Z
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-rw-r--r-- <span class="token number">1</span> root root <span class="token number">4506</span> Jul <span class="token number">27</span> <span class="token number">11</span>:43 man.config
|
||||
-rw-r--r-- <span class="token number">1</span> root root <span class="token number">2605</span> Jul <span class="token number">27</span> <span class="token number">11</span>:46 man.config.back.Z
|
||||
</code></pre>
|
||||
<p>这个<code>-c</code>的选项比较有趣!会将压缩过程的资料输出到屏幕上,而不是写入成为file.Z文件。所以,我们可以透过资料流重导向的方法将资料输出成为另一个档名。</p>
|
||||
|
|
@ -115,7 +133,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199260"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199260"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220528"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220528"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,consoletype,输出已连接的终端类型">
|
||||
<title>consoletype 命令,Linux consoletype 命令详解:输出已连接的终端类型 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199264">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220532">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,13 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>consoletype命令</strong> 用于打印已连接的终端类型到标准输出,并能够检查已连接的终端是当前终端还是虚拟终端。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">consoletype
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="consoletype
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">consoletype
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># consoletype</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# consoletype
|
||||
pty
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># consoletype</span>
|
||||
pty
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -88,7 +91,7 @@ pty
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199265"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199265"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220532"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220532"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,continue,结束本次循环,继续执行下一个for,while或until循环。">
|
||||
<title>continue 命令,Linux continue 命令详解:结束本次循环,继续执行下一个for,while或until循环。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199280">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220544">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="continue"><a class="anchor" aria-hidden="true" tabindex="-1" href="#continue"><span class="octicon octicon-link"></span></a>continue</h1>
|
||||
<p>结束本次循环,继续执行下一个for,while或until循环。</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">continue</span> <span class="token punctuation">[</span>n<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="continue [n]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">continue</span> <span class="token punctuation">[</span>n<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -66,7 +67,25 @@
|
|||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回状态为成功除非n小于1。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># continue的可选参数n缺省值为1。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# continue的可选参数n缺省值为1。
|
||||
for((i=3;i>0;i--)); do
|
||||
# 跳到内层for循环继续执行。
|
||||
for((j=3;j>0;j--)); do
|
||||
if((j==2)); then
|
||||
# 换成continue 1时结果一样
|
||||
continue
|
||||
fi
|
||||
printf "%s %s\n" ${i} ${j}
|
||||
done
|
||||
done
|
||||
# 输出结果
|
||||
3 3
|
||||
3 1
|
||||
2 3
|
||||
2 1
|
||||
1 3
|
||||
1 1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># continue的可选参数n缺省值为1。</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>i<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>i<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
<span class="token comment"># 跳到内层for循环继续执行。</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>j<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>j<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>j<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
|
|
@ -85,7 +104,21 @@
|
|||
<span class="token number">1</span> <span class="token number">3</span>
|
||||
<span class="token number">1</span> <span class="token number">1</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 当n为2时:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 当n为2时:
|
||||
# 跳到外层for循环继续执行。
|
||||
for((i=3;i>0;i--)); do
|
||||
for((j=3;j>0;j--)); do
|
||||
if((j==2)); then
|
||||
continue 2
|
||||
fi
|
||||
printf "%s %s\n" ${i} ${j}
|
||||
done
|
||||
done
|
||||
# 输出结果
|
||||
3 3
|
||||
2 3
|
||||
1 3
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 当n为2时:</span>
|
||||
<span class="token comment"># 跳到外层for循环继续执行。</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>i<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>i<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>i<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
<span class="token keyword">for</span><span class="token variable"><span class="token punctuation">((</span>j<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">;</span>j<span class="token operator">></span><span class="token number">0</span><span class="token punctuation">;</span>j<span class="token operator">--</span><span class="token punctuation">))</span></span><span class="token punctuation">;</span> <span class="token keyword">do</span>
|
||||
|
|
@ -129,7 +162,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199280"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199280"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220545"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220545"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,convertquota,把老的配额文件转换为新的格式">
|
||||
<title>convertquota 命令,Linux convertquota 命令详解:把老的配额文件转换为新的格式 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199286">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220551">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>convertquota命令</strong> 用于将老的磁盘额数据文件(“quota.user”和“quota.group”)转换为新格式的文件(“quota.user”和“quota.group”)。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">convertquota<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="convertquota(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">convertquota<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-u:仅转换用户磁盘配额数据文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-u:仅转换用户磁盘配额数据文件;
|
||||
-g:仅转换组磁盘配额数据文件;
|
||||
-f:将老的磁盘配额文件转换为新的格式;
|
||||
-e:将新的文件格式从大字节序换为小字节序。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-u:仅转换用户磁盘配额数据文件;
|
||||
-g:仅转换组磁盘配额数据文件;
|
||||
-f:将老的磁盘配额文件转换为新的格式;
|
||||
-e:将新的文件格式从大字节序换为小字节序。
|
||||
|
|
@ -69,7 +74,8 @@
|
|||
<p>文件系统:指定要转换磁盘配额数据文件格式的文件系统(硬盘分区)。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>使用convertquota指令转换指定文件系统<code>/data</code>的磁盘配额数据文件。在命令行中输入下面的命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell">convertquota -u /data //转换文件系统<span class="token string">"/data"</span>上的用户磁盘配额文件
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="convertquota -u /data //转换文件系统"/data"上的用户磁盘配额文件
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">convertquota -u /data //转换文件系统<span class="token string">"/data"</span>上的用户磁盘配额文件
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -96,7 +102,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199287"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199287"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220552"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220552"></script>
|
||||
</body>
|
||||
</html>
|
||||
71
c/cp.html
71
c/cp.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cp,将源文件或目录复制到目标文件或目录中">
|
||||
<title>cp 命令,Linux cp 命令详解:将源文件或目录复制到目标文件或目录中 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199301">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220567">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,23 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cp命令</strong> 用来将一个或多个源文件或者目录复制到指定的目的文件或目录。它可以将单个源文件复制成一个指定文件名的具体的文件或一个已经存在的目录下。cp命令还支持同时复制多个文件,当一次复制多个文件时,目标文件参数必须是一个已经存在的目录,否则将出现错误。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cp<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cp<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a:此参数的效果和同时指定<span class="token string">"-dpR"</span>参数相同;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a:此参数的效果和同时指定"-dpR"参数相同;
|
||||
-d:当复制符号连接时,把目标文件或目录也建立为符号连接,并指向与源文件或目录连接的原始文件或目录;
|
||||
-f:强行复制文件或目录,不论目标文件或目录是否已存在;
|
||||
-i:覆盖既有文件之前先询问用户;
|
||||
-l:对源文件建立硬连接,而非复制文件;
|
||||
-p:保留源文件或目录的属性;
|
||||
-R/r:递归处理,将指定目录下的所有文件与子目录一并处理;
|
||||
-s:对源文件建立符号连接,而非复制文件;
|
||||
-u:使用这项参数后只会在源文件的更改时间较目标文件更新时或是名称相互对应的目标文件并不存在时,才复制文件;
|
||||
-S:在备份文件时,用指定的后缀“SUFFIX”代替文件的默认后缀;
|
||||
-b:覆盖已存在的文件目标前将目标文件备份;
|
||||
-v:详细显示命令执行的操作。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a:此参数的效果和同时指定<span class="token string">"-dpR"</span>参数相同;
|
||||
-d:当复制符号连接时,把目标文件或目录也建立为符号连接,并指向与源文件或目录连接的原始文件或目录;
|
||||
-f:强行复制文件或目录,不论目标文件或目录是否已存在;
|
||||
-i:覆盖既有文件之前先询问用户;
|
||||
|
|
@ -81,28 +94,47 @@
|
|||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>下面的第一行中是 cp 命令和具体的参数(-r 是“递归”, -u 是“更新”,-v 是“详细”)。接下来的三行显示被复制文件的信息,最后一行显示命令行提示符。这样,只拷贝新的文件到我的存储设备上,我就使用 cp 的“更新”和“详细”选项。</p>
|
||||
<p>通常来说,参数 <code>-r</code> 也可用更详细的风格 <code>--recursive</code>。但是以简短的方式,也可以这么连用 <code>-ruv</code>。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> -r -u -v /usr/men/tmp ~/men/tmp
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp -r -u -v /usr/men/tmp ~/men/tmp
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> -r -u -v /usr/men/tmp ~/men/tmp
|
||||
</code></pre>
|
||||
<p>版本备份 <code>--backup=numbered</code> 参数意思为“我要做个备份,而且是带编号的连续备份”。所以一个备份就是 1 号,第二个就是 2 号,等等。</p>
|
||||
<pre class="language-shell"><code class="language-shell">$ <span class="token function">cp</span> --force --backup<span class="token operator">=</span>numbered test1.py test1.py
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="$ cp --force --backup=numbered test1.py test1.py
|
||||
$ ls
|
||||
test1.py test1.py.~1~ test1.py.~2~
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">$ <span class="token function">cp</span> --force --backup<span class="token operator">=</span>numbered test1.py test1.py
|
||||
$ <span class="token function">ls</span>
|
||||
test1.py test1.py.~1~ test1.py.~2~
|
||||
</code></pre>
|
||||
<p>如果把一个文件复制到一个目标文件中,而目标文件已经存在,那么,该目标文件的内容将被破坏。此命令中所有参数既可以是绝对路径名,也可以是相对路径名。通常会用到点<code>.</code>或点点<code>..</code>的形式。例如,下面的命令将指定文件复制到当前目录下:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> <span class="token punctuation">..</span>/mary/homework/assign <span class="token builtin class-name">.</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp ../mary/homework/assign .
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> <span class="token punctuation">..</span>/mary/homework/assign <span class="token builtin class-name">.</span>
|
||||
</code></pre>
|
||||
<p>所有目标文件指定的目录必须是己经存在的,cp命令不能创建目录。如果没有文件复制的权限,则系统会显示出错信息。</p>
|
||||
<p>将文件file复制到目录<code>/usr/men/tmp</code>下,并改名为file1</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> <span class="token function">file</span> /usr/men/tmp/file1
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp file /usr/men/tmp/file1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> <span class="token function">file</span> /usr/men/tmp/file1
|
||||
</code></pre>
|
||||
<p>将目录<code>/usr/men</code>下的所有文件及其子目录复制到目录<code>/usr/zh</code>中</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> -r /usr/men /usr/zh
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp -r /usr/men /usr/zh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> -r /usr/men /usr/zh
|
||||
</code></pre>
|
||||
<p>交互式地将目录<code>/usr/men</code>中的以m打头的所有.c文件复制到目录<code>/usr/zh</code>中</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> -i /usr/men m*.c /usr/zh
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp -i /usr/men m*.c /usr/zh
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> -i /usr/men m*.c /usr/zh
|
||||
</code></pre>
|
||||
<p>我们在Linux下使用cp命令复制文件时候,有时候会需要覆盖一些同名文件,覆盖文件的时候都会有提示:需要不停的按Y来确定执行覆盖。文件数量不多还好,但是要是几百个估计按Y都要吐血了,于是折腾来半天总结了一个方法:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> aaa/* /bbb
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp aaa/* /bbb
|
||||
# 复制目录aaa下所有到/bbb目录下,这时如果/bbb目录下有和aaa同名的文件,需要按Y来确认并且会略过aaa目录下的子目录。
|
||||
|
||||
cp -r aaa/* /bbb
|
||||
# 这次依然需要按Y来确认操作,但是没有忽略子目录。
|
||||
|
||||
cp -r -a aaa/* /bbb
|
||||
# 依然需要按Y来确认操作,并且把aaa目录以及子目录和文件属性也传递到了/bbb。
|
||||
|
||||
\cp -r -a aaa/* /bbb
|
||||
# 成功,没有提示按Y、传递了目录属性、没有略过目录。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> aaa/* /bbb
|
||||
<span class="token comment"># 复制目录aaa下所有到/bbb目录下,这时如果/bbb目录下有和aaa同名的文件,需要按Y来确认并且会略过aaa目录下的子目录。</span>
|
||||
|
||||
<span class="token function">cp</span> -r aaa/* /bbb
|
||||
|
|
@ -115,18 +147,27 @@ test1.py test1.py.~1~ test1.py.~2~
|
|||
<span class="token comment"># 成功,没有提示按Y、传递了目录属性、没有略过目录。</span>
|
||||
</code></pre>
|
||||
<p>递归强制复制目录到指定目录中覆盖已存在文件</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> -rfb ./* <span class="token punctuation">..</span>/backup
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp -rfb ./* ../backup
|
||||
# 将当前目录下所有文件,复制到当前目录的兄弟目录 backup 文件夹中
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> -rfb ./* <span class="token punctuation">..</span>/backup
|
||||
<span class="token comment"># 将当前目录下所有文件,复制到当前目录的兄弟目录 backup 文件夹中</span>
|
||||
</code></pre>
|
||||
<p>拷贝目录下的隐藏文件如 <code>.babelrc</code></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> -r aaa/.* ./bbb
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp -r aaa/.* ./bbb
|
||||
# 将 aaa 目录下的,所有`.`开头的文件,复制到 bbb 目录中。
|
||||
|
||||
cp -a aaa ./bbb/
|
||||
# 记住后面目录最好的'/' 带上 `-a` 参数
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> -r aaa/.* ./bbb
|
||||
<span class="token comment"># 将 aaa 目录下的,所有`.`开头的文件,复制到 bbb 目录中。</span>
|
||||
|
||||
<span class="token function">cp</span> -a aaa ./bbb/
|
||||
<span class="token comment"># 记住后面目录最好的'/' 带上 `-a` 参数</span>
|
||||
</code></pre>
|
||||
<p>复制到当前目录</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cp</span> aaa.conf ./
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cp aaa.conf ./
|
||||
# 将 aaa.conf 复制到当前目录
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cp</span> aaa.conf ./
|
||||
<span class="token comment"># 将 aaa.conf 复制到当前目录</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -154,7 +195,7 @@ test1.py test1.py.~1~ test1.py.~2~
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199302"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199302"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220567"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220567"></script>
|
||||
</body>
|
||||
</html>
|
||||
63
c/cpio.html
63
c/cpio.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cpio,用来建立、还原备份档的工具程序">
|
||||
<title>cpio 命令,Linux cpio 命令详解:用来建立、还原备份档的工具程序 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199314">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220578">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,51 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cpio命令</strong> 主要是用来建立或者还原备份档的工具程序,cpio命令可以复制文件到归档包中,或者从归档包中复制文件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cpio<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cpio(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cpio<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-0或--null:接受新增列控制字符,通常配合find指令的“-print0”参数使用;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-0或--null:接受新增列控制字符,通常配合find指令的“-print0”参数使用;
|
||||
-a或--rest-access-time:重新设置文件的存取时间;
|
||||
-A或--append:附加到已存在的备份文档中,且这个备份文档必须存放在磁盘上,而不能放置于磁带机里;
|
||||
-b或--awap:此参数的效果和同时指定“-ss”参数相同;
|
||||
-B:将输入/输出的区块大小改成5210Bytes;
|
||||
-c:使用旧ASCII备份格式;
|
||||
-C<区块大小>或--io-size=<区块大小>:设置输入/输出的区块大小,单位是Byte;
|
||||
-d或--make-directories:如有需要cpio会自行建立目录;
|
||||
-E<范本文件>或--pattern-file=<范本文件>:指定范本文件,其内含有一个或多个范本样式,让cpio解开符合范本条件的文件,格式为每列一个范本样式;
|
||||
-f或--nonmatching:让cpio解开所有不符合范本条件的文件;
|
||||
-F<备份档>或--file=<备份档>:指定备份档的名称,用来取代标准输入或输出,也能借此通过网络使用另一台主机的保存设备存取备份档;
|
||||
-H<备份格式>:指定备份时欲使用的文件格式;
|
||||
-i或--extract:执行copy-in模式,还原备份档;
|
||||
-l<备份档>:指定备份档的名称,用来取代标准输入,也能借此通过网络使用另一台主机的保存设备读取备份档;
|
||||
-k:此参数将忽略不予处理,仅负责解决cpio不同版本间的兼容性问题;
|
||||
-l或--link:以硬连接的方式取代复制文件,可在copy-pass模式下运用;
|
||||
-L或--dereference:不建立符号连接,直接复制该连接所指向的原始文件;
|
||||
-m或preserve-modification-time:不去更改文件的更改时间;
|
||||
-M<回传信息>或--message=<回传信息>:设置更换保存媒体的信息;
|
||||
-n或--numeric-uid-gid:使用“-tv”参数列出备份档的内容时,若再加上参数“-n”,则会以用户识别和群组识别码替代拥有者和群组名称列出文件清单;
|
||||
-o或--create:执行copy-out模式,建立备份档;
|
||||
-O<备份档>:指定备份档的名称,用来取代标准输出,也能借此通过网络使用另一台主机的保存设备存放备份档;
|
||||
-p或--pass-through:执行copy-pass模式,略过备份步骤,直接将文件复制到目的目录;
|
||||
-r或--rename:当有文件名称需要更改时,采用互动模式;
|
||||
-R<拥有者><:/.><所属群组>或----owner<拥有者><:/.><所属群组> 在copy-in模式还原备份档,或copy-pass模式复制文件时,可指定这些备份,复制的文件的拥有者与所属群组;
|
||||
-s或--swap-bytes:交换每队字节的内容;
|
||||
-S或--swap-halfwords:交换每半个字节的内容;
|
||||
-t或--list:将输入的内容呈现出来;
|
||||
-u或--unconditional:置换所有文件,不论日期时间的新旧与否,皆不予询问而直接覆盖;
|
||||
-v或--verbose:详细显示指令的执行过程;
|
||||
-V或--dot:执行指令时。在每个文件的执行程序前面加上“.”号;
|
||||
--block-size=<区块大小>:设置输入/输出的区块大小,假如设置数值为5,则区块大小为2500,若设置成10,则区块大小为5120,以此类推;
|
||||
--force-local:强制将备份档存放在本地主机;
|
||||
--help:在线帮助;
|
||||
--no-absolute-filenames:使用相对路径建立文件名称;
|
||||
--no-preserve-owner:不保留文件的拥有者,谁解开了备份档,那些文件就归谁所有;
|
||||
-only-verify-crc:当备份档采用CRC备份格式时,可使用这项参数检查备份档内的每个文件是否正确无误;
|
||||
--quiet:不显示复制了多少区块;
|
||||
--sparse:倘若一个文件内含有大量的连续0字节,则将此文件存在稀疏文件;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-0或--null:接受新增列控制字符,通常配合find指令的“-print0”参数使用;
|
||||
-a或--rest-access-time:重新设置文件的存取时间;
|
||||
-A或--append:附加到已存在的备份文档中,且这个备份文档必须存放在磁盘上,而不能放置于磁带机里;
|
||||
-b或--awap:此参数的效果和同时指定“-ss”参数相同;
|
||||
|
|
@ -103,18 +144,22 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p><strong>将<code>/etc</code>下的所有普通文件都备份到<code>/opt/etc.cpio</code>,使用以下命令:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">find</span> /etc –type f <span class="token operator">|</span> cpio –ocvB <span class="token operator">></span>/opt/etc.cpio
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="find /etc –type f | cpio –ocvB >/opt/etc.cpio
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">find</span> /etc –type f <span class="token operator">|</span> cpio –ocvB <span class="token operator">></span>/opt/etc.cpio
|
||||
</code></pre>
|
||||
<p><strong>将系统上所有资料备份到磁带机内,使用以下命令:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">find</span> / -print <span class="token operator">|</span> cpio -covB <span class="token operator">></span> /dev/st0
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="find / -print | cpio -covB > /dev/st0
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">find</span> / -print <span class="token operator">|</span> cpio -covB <span class="token operator">></span> /dev/st0
|
||||
</code></pre>
|
||||
<p>这里的<code>/dev/st0</code>是磁带的设备名,代表SCSI磁带机。</p>
|
||||
<p><strong>查看上例磁带机上备份的文件,使用以下命令:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell">cpio -icdvt <span class="token operator"><</span> /dev/st0 <span class="token operator">></span> /tmp/st_content
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cpio -icdvt < /dev/st0 > /tmp/st_content
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cpio -icdvt <span class="token operator"><</span> /dev/st0 <span class="token operator">></span> /tmp/st_content
|
||||
</code></pre>
|
||||
<p>有时可能因为备份的文件过多,一个屏幕无法显示完毕,此时我们利用下面命令,让磁带机的文件信息输出到文件。</p>
|
||||
<p><strong>将示例1中的备份包还原到相应的位置,如果有相同文件进行覆盖,使用以下命令:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell">cpio –icduv <span class="token operator"><</span> /opt/etc.cpio
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cpio –icduv < /opt/etc.cpio
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cpio –icduv <span class="token operator"><</span> /opt/etc.cpio
|
||||
</code></pre>
|
||||
<p>注意,cpio恢复的路径,如果cpio在打包备份的时候用的是绝对路径,那么在恢复的时候会自动恢复到这些绝对路径下,本例就会将备份文件全部还原到/etc路径下对应的目录中。同理,如果在打包备份用的是相对路径,还原时也将恢复到相对路径下。</p>
|
||||
<p>通过上面的示例,可以看出,cpio无法直接读取文件,它需要每个文件或者目录的完整路径名才能识别读取,而find命令的输出刚好做到了这点,因此,cpio命令一般和find命令配合使用。其实,上面的示例我们已经看到了它们的组合用法。</p>
|
||||
|
|
@ -143,7 +188,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199315"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199315"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220580"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220580"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,crontab,提交和管理用户的需要周期性执行的任务">
|
||||
<title>crontab 命令,Linux crontab 命令详解:提交和管理用户的需要周期性执行的任务 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199342">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220609">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>crontab命令</strong> 被用来提交和管理用户的需要周期性执行的任务,与windows下的计划任务类似,当安装完成操作系统后,默认会安装此服务工具,并且会自动启动crond进程,crond进程每分钟会定期检查是否有要执行的任务,如果有要执行的任务,则自动执行该任务。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">crontab<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="crontab(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">crontab<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-e:编辑该用户的计时器设置;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-e:编辑该用户的计时器设置;
|
||||
-l:列出该用户的计时器设置;
|
||||
-r:删除该用户的计时器设置;
|
||||
-u<用户名称>:指定要设定计时器的用户名称。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-e:编辑该用户的计时器设置;
|
||||
-l:列出该用户的计时器设置;
|
||||
-r:删除该用户的计时器设置;
|
||||
-u<span class="token operator"><</span>用户名称<span class="token operator">></span>:指定要设定计时器的用户名称。
|
||||
|
|
@ -71,7 +76,16 @@
|
|||
<p>Linux下的任务调度分为两类: <strong>系统任务调度</strong> 和 <strong>用户任务调度</strong> 。</p>
|
||||
<p><strong>系统任务调度:</strong> 系统周期性所要执行的工作,比如写缓存数据到硬盘、日志清理等。在<code>/etc</code>目录下有一个crontab文件,这个就是系统任务调度的配置文件。</p>
|
||||
<p><code>/etc/crontab</code>文件包括下面几行:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable"><span class="token environment constant">SHELL</span></span><span class="token operator">=</span>/bin/bash
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="SHELL=/bin/bash
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
MAILTO=""HOME=/
|
||||
|
||||
# run-parts
|
||||
51 * * * * root run-parts /etc/cron.hourly
|
||||
24 7 * * * root run-parts /etc/cron.daily
|
||||
22 4 * * 0 root run-parts /etc/cron.weekly
|
||||
42 4 1 * * root run-parts /etc/cron.monthly
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable"><span class="token environment constant">SHELL</span></span><span class="token operator">=</span>/bin/bash
|
||||
<span class="token assign-left variable"><span class="token environment constant">PATH</span></span><span class="token operator">=</span>/sbin:/bin:/usr/sbin:/usr/bin
|
||||
<span class="token assign-left variable">MAILTO</span><span class="token operator">=</span><span class="token string">""</span><span class="token environment constant">HOME</span><span class="token operator">=</span>/
|
||||
|
||||
|
|
@ -83,12 +97,16 @@
|
|||
</code></pre>
|
||||
<p>前四行是用来配置crond任务运行的环境变量,第一行SHELL变量指定了系统要使用哪个shell,这里是bash,第二行PATH变量指定了系统执行命令的路径,第三行MAILTO变量指定了crond的任务执行信息将通过电子邮件发送给root用户,如果MAILTO变量的值为空,则表示不发送任务执行信息给用户,第四行的HOME变量指定了在执行命令或者脚本时使用的主目录。</p>
|
||||
<p><strong>用户任务调度:</strong> 用户定期要执行的工作,比如用户数据备份、定时邮件提醒等。用户可以使用 crontab 工具来定制自己的计划任务。所有用户定义的crontab文件都被保存在<code>/var/spool/cron</code>目录中。其文件名与用户名一致,使用者权限文件如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">/etc/cron.deny 该文件中所列用户不允许使用crontab命令
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="/etc/cron.deny 该文件中所列用户不允许使用crontab命令
|
||||
/etc/cron.allow 该文件中所列用户允许使用crontab命令
|
||||
/var/spool/cron/ 所有用户crontab文件存放的目录,以用户名命名
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">/etc/cron.deny 该文件中所列用户不允许使用crontab命令
|
||||
/etc/cron.allow 该文件中所列用户允许使用crontab命令
|
||||
/var/spool/cron/ 所有用户crontab文件存放的目录,以用户名命名
|
||||
</code></pre>
|
||||
<p>crontab文件的含义:用户所建立的crontab文件中,每一行都代表一项任务,每行的每个字段代表一项设置,它的格式共分为六个字段,前五段是时间设定段,第六段是要执行的命令段,格式如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">minute hour day month week <span class="token builtin class-name">command</span> 顺序:分 时 日 月 周
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="minute hour day month week command 顺序:分 时 日 月 周
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">minute hour day month week <span class="token builtin class-name">command</span> 顺序:分 时 日 月 周
|
||||
</code></pre>
|
||||
<p>其中:</p>
|
||||
<ul>
|
||||
|
|
@ -107,68 +125,91 @@
|
|||
<li>正斜线(/):可以用正斜线指定时间的间隔频率,例如“0-23/2”表示每两小时执行一次。同时正斜线可以和星号一起使用,例如*/10,如果用在minute字段,表示每十分钟执行一次。</li>
|
||||
</ul>
|
||||
<p><strong>crond服务</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell">/sbin/service crond start <span class="token comment"># 启动服务</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="/sbin/service crond start # 启动服务
|
||||
/sbin/service crond stop # 关闭服务
|
||||
/sbin/service crond restart # 重启服务
|
||||
/sbin/service crond reload # 重新载入配置
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">/sbin/service crond start <span class="token comment"># 启动服务</span>
|
||||
/sbin/service crond stop <span class="token comment"># 关闭服务</span>
|
||||
/sbin/service crond restart <span class="token comment"># 重启服务</span>
|
||||
/sbin/service crond reload <span class="token comment"># 重新载入配置</span>
|
||||
</code></pre>
|
||||
<p>查看crontab服务状态:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">service</span> crond status
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="service crond status
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">service</span> crond status
|
||||
</code></pre>
|
||||
<p>手动启动crontab服务:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">service</span> crond start
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="service crond start
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">service</span> crond start
|
||||
</code></pre>
|
||||
<p>查看crontab服务是否已设置为开机启动,执行命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell">ntsysv
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="ntsysv
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">ntsysv
|
||||
</code></pre>
|
||||
<p>加入开机自动启动:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">chkconfig</span> –level <span class="token number">35</span> crond on
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="chkconfig –level 35 crond on
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">chkconfig</span> –level <span class="token number">35</span> crond on
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>每1分钟执行一次command</p>
|
||||
<pre class="language-shell"><code class="language-shell">* * * * * <span class="token builtin class-name">command</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="* * * * * command
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">* * * * * <span class="token builtin class-name">command</span>
|
||||
</code></pre>
|
||||
<p>每小时的第3和第15分钟执行</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">3,15</span> * * * * <span class="token builtin class-name">command</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="3,15 * * * * command
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">3,15</span> * * * * <span class="token builtin class-name">command</span>
|
||||
</code></pre>
|
||||
<p>在上午8点到11点的第3和第15分钟执行</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 * * * <span class="token builtin class-name">command</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="3,15 8-11 * * * command
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 * * * <span class="token builtin class-name">command</span>
|
||||
</code></pre>
|
||||
<p>每隔两天的上午8点到11点的第3和第15分钟执行</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 */2 * * <span class="token builtin class-name">command</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="3,15 8-11 */2 * * command
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 */2 * * <span class="token builtin class-name">command</span>
|
||||
</code></pre>
|
||||
<p>每个星期一的上午8点到11点的第3和第15分钟执行</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 * * <span class="token number">1</span> <span class="token builtin class-name">command</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="3,15 8-11 * * 1 command
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">3,15</span> <span class="token number">8</span>-11 * * <span class="token number">1</span> <span class="token builtin class-name">command</span>
|
||||
</code></pre>
|
||||
<p>每晚的21:30重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">30</span> <span class="token number">21</span> * * * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="30 21 * * * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">30</span> <span class="token number">21</span> * * * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每月1、10、22日的4 : 45重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">45</span> <span class="token number">4</span> <span class="token number">1,10</span>,22 * * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="45 4 1,10,22 * * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">45</span> <span class="token number">4</span> <span class="token number">1,10</span>,22 * * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每周六、周日的1:10重启smb</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">10</span> <span class="token number">1</span> * * <span class="token number">6,0</span> /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="10 1 * * 6,0 /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">10</span> <span class="token number">1</span> * * <span class="token number">6,0</span> /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每天18 : 00至23 : 00之间每隔30分钟重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0,30</span> <span class="token number">18</span>-23 * * * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0,30 18-23 * * * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0,30</span> <span class="token number">18</span>-23 * * * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每星期六的晚上11:00 pm重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0</span> <span class="token number">23</span> * * <span class="token number">6</span> /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0 23 * * 6 /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0</span> <span class="token number">23</span> * * <span class="token number">6</span> /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每一小时重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell">* */1 * * * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="* */1 * * * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">* */1 * * * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>晚上11点到早上7点之间,每隔一小时重启smb</p>
|
||||
<pre class="language-shell"><code class="language-shell">* <span class="token number">23</span>-7/1 * * * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="* 23-7/1 * * * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">* <span class="token number">23</span>-7/1 * * * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每月的4号与每周一到周三的11点重启smb </p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0</span> <span class="token number">11</span> <span class="token number">4</span> * mon-wed /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0 11 4 * mon-wed /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0</span> <span class="token number">11</span> <span class="token number">4</span> * mon-wed /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>一月一号的4点重启smb</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0</span> <span class="token number">4</span> <span class="token number">1</span> jan * /etc/init.d/smb restart
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0 4 1 jan * /etc/init.d/smb restart
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0</span> <span class="token number">4</span> <span class="token number">1</span> jan * /etc/init.d/smb restart
|
||||
</code></pre>
|
||||
<p>每小时执行<code>/etc/cron.hourly</code>目录内的脚本</p>
|
||||
<pre class="language-shell"><code class="language-shell">01 * * * * root run-parts /etc/cron.hourly
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="01 * * * * root run-parts /etc/cron.hourly
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">01 * * * * root run-parts /etc/cron.hourly
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -195,7 +236,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199343"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199343"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220610"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220610"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,csplit,将一个大文件分割成小的碎片文件">
|
||||
<title>csplit 命令,Linux csplit 命令详解:将一个大文件分割成小的碎片文件 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199355">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220621">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>csplit命令</strong> 用于将一个大文件分割成小的碎片,并且将分割后的每个碎片保存成一个文件。碎片文件的命名类似“xx00”,“xx01”。csplit命令是split的一个变体,split只能够根据文件大小或行数来分割,但csplit能够根据文件本身特点来分割文件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">csplit<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="csplit(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">csplit<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b<span class="token operator"><</span>输出格式<span class="token operator">></span>或--suffix-format<span class="token operator">=</span><span class="token operator"><</span>输出格式<span class="token operator">></span>:预设的输出格式其文件名称为xx00,xx01等,用户可以通过改变<span class="token operator"><</span>输出格式<span class="token operator">></span>来改变输出的文件名;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b<输出格式>或--suffix-format=<输出格式>:预设的输出格式其文件名称为xx00,xx01等,用户可以通过改变<输出格式>来改变输出的文件名;
|
||||
-f<输出字首字符串>或--prefix=<输出字首字符串>:预设的输出字首字符串其文件名为xx00,xx01等,如果制定输出字首字符串为“hello”,则输出的文件名称会变成hello00,hello、01......
|
||||
-k或--keep-files:保留文件,就算发生错误或中断执行,与不能删除已经输出保存的文件;
|
||||
-n<输出文件名位数>或--digits=<输出文件名位数>:预设的输出文件名位数其文件名称为xx00,xx01......如果用户指定输出文件名位数为“3”,则输出的文件名称会变成xx000,xx001等;
|
||||
-q或-s或--quiet或——silent:不显示指令执行过程;
|
||||
-z或--elide-empty-files:删除长度为0 Byte文件。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b<span class="token operator"><</span>输出格式<span class="token operator">></span>或--suffix-format<span class="token operator">=</span><span class="token operator"><</span>输出格式<span class="token operator">></span>:预设的输出格式其文件名称为xx00,xx01等,用户可以通过改变<span class="token operator"><</span>输出格式<span class="token operator">></span>来改变输出的文件名;
|
||||
-f<span class="token operator"><</span>输出字首字符串<span class="token operator">></span>或--prefix<span class="token operator">=</span><span class="token operator"><</span>输出字首字符串<span class="token operator">></span>:预设的输出字首字符串其文件名为xx00,xx01等,如果制定输出字首字符串为“hello”,则输出的文件名称会变成hello00,hello、01<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
|
||||
-k或--keep-files:保留文件,就算发生错误或中断执行,与不能删除已经输出保存的文件;
|
||||
-n<span class="token operator"><</span>输出文件名位数<span class="token operator">></span>或--digits<span class="token operator">=</span><span class="token operator"><</span>输出文件名位数<span class="token operator">></span>:预设的输出文件名位数其文件名称为xx00,xx01<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>如果用户指定输出文件名位数为“3”,则输出的文件名称会变成xx000,xx001等;
|
||||
|
|
@ -74,7 +81,23 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>示例测试文件 server.log</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> server.log
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat server.log
|
||||
SERVER-1
|
||||
[con] 10.10.10.1 suc
|
||||
[con] 10.10.10.2 fai
|
||||
[dis] 10.10.10.3 pen
|
||||
[con] 10.10.10.4 suc
|
||||
SERVER-2
|
||||
[con] 10.10.10.5 suc
|
||||
[con] 10.10.10.6 fai
|
||||
[dis] 10.10.10.7 pen
|
||||
[con] 10.10.10.8 suc
|
||||
SERVER-3
|
||||
[con] 10.10.10.9 suc
|
||||
[con] 10.10.10.10 fai
|
||||
[dis] 10.10.10.11 pen
|
||||
[con] 10.10.10.12 suc
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> server.log
|
||||
SERVER-1
|
||||
<span class="token punctuation">[</span>con<span class="token punctuation">]</span> <span class="token number">10.10</span>.10.1 suc
|
||||
<span class="token punctuation">[</span>con<span class="token punctuation">]</span> <span class="token number">10.10</span>.10.2 fai
|
||||
|
|
@ -92,12 +115,22 @@ SERVER-3
|
|||
<span class="token punctuation">[</span>con<span class="token punctuation">]</span> <span class="token number">10.10</span>.10.12 suc
|
||||
</code></pre>
|
||||
<p>需要将server.log分割成server1.log、server2.log、server3.log,这些文件的内容分别取自原文件中不同的SERVER部分:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost split<span class="token punctuation">]</span><span class="token comment"># csplit server.log /SERVER/ -n2 -s {*} -f server -b "%02d.log"; rm server00.log</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost split]# csplit server.log /SERVER/ -n2 -s {*} -f server -b "%02d.log"; rm server00.log
|
||||
[root@localhost split]# ls
|
||||
server01.log server02.log server03.log server.log
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost split<span class="token punctuation">]</span><span class="token comment"># csplit server.log /SERVER/ -n2 -s {*} -f server -b "%02d.log"; rm server00.log</span>
|
||||
<span class="token punctuation">[</span>root@localhost split<span class="token punctuation">]</span><span class="token comment"># ls</span>
|
||||
server01.log server02.log server03.log server.log
|
||||
</code></pre>
|
||||
<p><strong>命令详细说明:</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell">/<span class="token punctuation">[</span>正则表达式<span class="token punctuation">]</span>/ <span class="token comment">#匹配文本样式,比如/SERVER/,从第一行到包含SERVER的匹配行。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="/[正则表达式]/ #匹配文本样式,比如/SERVER/,从第一行到包含SERVER的匹配行。
|
||||
{*} #表示根据匹配重复执行分割,直到文件尾停止,使用{整数}的形式指定分割执行的次数。
|
||||
-s #静默模式,不打印其他信息。
|
||||
-n #指定分割后的文件名后缀的数字个数。比如01、02、03等。
|
||||
-f #指定分割后的文件名前缀。
|
||||
-b #指定后缀格式。比如%02d.log,类似于C语言中的printf参数格式。
|
||||
rm server00.log #是删除第一个文件,因为分割后的的第一个文件没有内容,匹配的单词就位于文件的第一行中。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">/<span class="token punctuation">[</span>正则表达式<span class="token punctuation">]</span>/ <span class="token comment">#匹配文本样式,比如/SERVER/,从第一行到包含SERVER的匹配行。</span>
|
||||
<span class="token punctuation">{</span>*<span class="token punctuation">}</span> <span class="token comment">#表示根据匹配重复执行分割,直到文件尾停止,使用{整数}的形式指定分割执行的次数。</span>
|
||||
-s <span class="token comment">#静默模式,不打印其他信息。</span>
|
||||
-n <span class="token comment">#指定分割后的文件名后缀的数字个数。比如01、02、03等。</span>
|
||||
|
|
@ -130,7 +163,7 @@ server01.log server02.log server03.log server.log
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199356"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199356"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220622"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220622"></script>
|
||||
</body>
|
||||
</html>
|
||||
34
c/cu.html
34
c/cu.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cu,用于连接另一个系统主机">
|
||||
<title>cu 命令,Linux cu 命令详解:用于连接另一个系统主机 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199366">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220633">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,11 +57,31 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cu命令</strong> 用于连接另一个系统主机。cu(call up)指令可连接另一台主机,并采用类似拨号终端机的接口工作,也可执行简易的文件传输作业。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cu <span class="token punctuation">[</span>dehnotv<span class="token punctuation">]</span><span class="token punctuation">[</span>-a<span class="token operator"><</span>通信端口<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-c<span class="token operator"><</span>电话号码<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-E<span class="token operator"><</span>脱离字符<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-I<span class="token operator"><</span>设置文件<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-l<span class="token operator"><</span>外围设备代号<span class="token operator">></span><span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cu [dehnotv][-a<通信端口>][-c<电话号码>][-E<脱离字符>][-I<设置文件>][-l<外围设备代号>]
|
||||
[-s<连线速率>][-x<排错模式>][-z<系统主机>][--help][-nostop][--parity=none][<系统主机>/<电话号码>]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cu <span class="token punctuation">[</span>dehnotv<span class="token punctuation">]</span><span class="token punctuation">[</span>-a<span class="token operator"><</span>通信端口<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-c<span class="token operator"><</span>电话号码<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-E<span class="token operator"><</span>脱离字符<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-I<span class="token operator"><</span>设置文件<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-l<span class="token operator"><</span>外围设备代号<span class="token operator">></span><span class="token punctuation">]</span>
|
||||
<span class="token punctuation">[</span>-s<span class="token operator"><</span>连线速率<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-x<span class="token operator"><</span>排错模式<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>-z<span class="token operator"><</span>系统主机<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">[</span>--help<span class="token punctuation">]</span><span class="token punctuation">[</span>-nostop<span class="token punctuation">]</span><span class="token punctuation">[</span>--parity<span class="token operator">=</span>none<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token operator"><</span>系统主机<span class="token operator">></span>/<span class="token operator"><</span>电话号码<span class="token operator">></span><span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a<span class="token operator"><</span>通信端口<span class="token operator">></span>或-p<span class="token operator"><</span>通信端口<span class="token operator">></span>或--port<span class="token operator"><</span>通信端口<span class="token operator">></span> 使用指定的通信端口进行连线。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a<通信端口>或-p<通信端口>或--port<通信端口> 使用指定的通信端口进行连线。
|
||||
-c<电话号码>或--phone<电话号码> 拨打该电话号码。
|
||||
-d 进入排错模式。
|
||||
-e或--parity=even 使用双同位检查。
|
||||
-E<脱离字符>或--escape<脱离字符> 设置脱离字符。
|
||||
-h或--halfduple 使用半双工模式。
|
||||
-I<配置文件>或--config<配置文件> 指定要使用的配置文件。
|
||||
-l<外围设备代号>或--line<外围设备代号> 指定某项外围设备,作为连接的设备。
|
||||
-n或--prompt 拨号时等待用户输入电话号码。
|
||||
-o或--parity=odd 使用单同位检查。
|
||||
-s<连线速率>或--speed<连线速率>或--baud<连线速率>或-<连线速率> 设置连线的速率,单位以鲍率计算。
|
||||
-t或--maper 把CR字符置换成LF+CR字符。
|
||||
-v或--version 显示版本信息。
|
||||
-x<排错模式>或--debug<排错模式> 使用排错模式。
|
||||
-z<系统主机>或--system<系统主机> 连接该系统主机。
|
||||
--help 在线帮助。
|
||||
--nostop 关闭Xon/Xoff软件流量控制。
|
||||
--parity=none 不使用同位检查。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a<span class="token operator"><</span>通信端口<span class="token operator">></span>或-p<span class="token operator"><</span>通信端口<span class="token operator">></span>或--port<span class="token operator"><</span>通信端口<span class="token operator">></span> 使用指定的通信端口进行连线。
|
||||
-c<span class="token operator"><</span>电话号码<span class="token operator">></span>或--phone<span class="token operator"><</span>电话号码<span class="token operator">></span> 拨打该电话号码。
|
||||
-d 进入排错模式。
|
||||
-e或--parity<span class="token operator">=</span>even 使用双同位检查。
|
||||
|
|
@ -82,7 +102,9 @@
|
|||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>与远程主机连接</p>
|
||||
<pre class="language-shell"><code class="language-shell">cu -c 0102377765
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cu -c 0102377765
|
||||
cu -s 38400 9=12015551234
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cu -c 0102377765
|
||||
cu -s <span class="token number">38400</span> <span class="token assign-left variable">9</span><span class="token operator">=</span><span class="token number">12015551234</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -110,7 +132,7 @@ cu -s <span class="token number">38400</span> <span class="token assign-left var
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199367"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199367"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220634"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220634"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cupsdisable,停止指定的打印机">
|
||||
<title>cupsdisable 命令,Linux cupsdisable 命令详解:停止指定的打印机 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199372">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220640">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,17 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cupsdisable命令</strong> 用于停止指定的打印机。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cupsdisable<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cupsdisable(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cupsdisable<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-E:当连接到服务器时强制使用加密;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
-c:取消指定打印机的所有打印任务;
|
||||
-h:指定连接的服务器名和端口号;
|
||||
-r:停止打印机的原因。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
-c:取消指定打印机的所有打印任务;
|
||||
|
|
@ -94,7 +101,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199373"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199373"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220640"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220640"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cupsenable,启动指定的打印机">
|
||||
<title>cupsenable 命令,Linux cupsenable 命令详解:启动指定的打印机 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199378">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220645">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>cupsenable命令</strong> 用于启动指定的打印机。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cupsenable<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cupsenable(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cupsenable<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-E:当连接到服务器时强制使用加密;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
-h:指定连接的服务器名和端口号;
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-E:当连接到服务器时强制使用加密;
|
||||
-U:指定连接服务器时使用的用户名;
|
||||
-u:指定打印任务所属的用户;
|
||||
-h:指定连接的服务器名和端口号;
|
||||
|
|
@ -92,7 +97,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199379"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199379"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220645"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220645"></script>
|
||||
</body>
|
||||
</html>
|
||||
209
c/curl.html
209
c/curl.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,curl,利用URL规则在命令行下工作的文件传输工具">
|
||||
<title>curl 命令,Linux curl 命令详解:利用URL规则在命令行下工作的文件传输工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199575">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220800">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,7 +57,8 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>curl命令</strong> 是一个利用URL规则在命令行下工作的文件传输工具。它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称curl为下载工具。作为一款强力工具,curl支持包括HTTP、HTTPS、ftp等众多协议,还支持POST、cookies、认证、从指定偏移处下载部分文件、用户代理字符串、限速、文件大小、进度条等特征。做网页处理流程和数据检索自动化,curl可以祝一臂之力。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">curl<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">curl<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
|
|
@ -543,27 +544,38 @@
|
|||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p><strong>文件下载</strong></p>
|
||||
<p>curl命令可以用来执行下载、发送各种HTTP请求,指定HTTP头部等操作。如果系统没有curl可以使用<code>yum install curl</code>安装,也可以下载安装。curl是将下载文件输出到stdout,将进度信息输出到stderr,不显示进度信息使用<code>--silent</code>选项。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL --silent
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL --silent
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL --silent
|
||||
</code></pre>
|
||||
<p>这条命令是将下载文件输出到终端,所有下载的数据都被写入到stdout。</p>
|
||||
<p>使用选项<code>-O</code>将下载的数据写入到文件,必须使用文件的绝对地址:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> http://example.com/text.iso --silent -O
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl http://example.com/text.iso --silent -O
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> http://example.com/text.iso --silent -O
|
||||
</code></pre>
|
||||
<p>选项<code>-o</code>将下载数据写入到指定名称的文件中,并使用<code>--progress</code>显示进度条:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> http://example.com/test.iso -o filename.iso --progress
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl http://example.com/test.iso -o filename.iso --progress
|
||||
######################################### 100.0%
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> http://example.com/test.iso -o filename.iso --progress
|
||||
<span class="token comment">######################################### 100.0%</span>
|
||||
</code></pre>
|
||||
<p><strong>不输出错误和进度信息</strong></p>
|
||||
<p><code>-s</code> 参数将不输出错误和进度信息。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -s https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -s https://www.example.com
|
||||
# 上面命令一旦发生错误,不会显示错误信息。不发生错误的话,会正常显示运行结果。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -s https://www.example.com
|
||||
<span class="token comment"># 上面命令一旦发生错误,不会显示错误信息。不发生错误的话,会正常显示运行结果。</span>
|
||||
</code></pre>
|
||||
<p>如果想让 curl 不产生任何输出,可以使用下面的命令。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -s -o /dev/null https://google.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -s -o /dev/null https://google.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -s -o /dev/null https://google.com
|
||||
</code></pre>
|
||||
<p><strong>断点续传</strong></p>
|
||||
<p>curl能够从特定的文件偏移处继续下载,它可以通过指定一个便宜量来下载部分文件:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL/File -C 偏移量
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL/File -C 偏移量
|
||||
|
||||
#偏移量是以字节为单位的整数,如果让curl自动推断出正确的续传位置使用-C -:
|
||||
curl -C -URL
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL/File -C 偏移量
|
||||
|
||||
<span class="token comment">#偏移量是以字节为单位的整数,如果让curl自动推断出正确的续传位置使用-C -:</span>
|
||||
<span class="token function">curl</span> -C -URL
|
||||
|
|
@ -571,36 +583,54 @@
|
|||
<p><strong>使用curl设置参照页字符串</strong></p>
|
||||
<p>参照页是位于HTTP头部中的一个字符串,用来表示用户是从哪个页面到达当前页面的,如果用户点击网页A中的某个连接,那么用户就会跳转到B网页,网页B头部的参照页字符串就包含网页A的URL。</p>
|
||||
<p>使用<code>--referer</code>选项指定参照页字符串:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> --referer http://www.google.com http://wangchujiang.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl --referer http://www.google.com http://wangchujiang.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> --referer http://www.google.com http://wangchujiang.com
|
||||
</code></pre>
|
||||
<p><strong>用curl设置用户代理字符串</strong></p>
|
||||
<p>有些网站访问会提示只能使用IE浏览器来访问,这是因为这些网站设置了检查用户代理,可以使用curl把用户代理设置为IE,这样就可以访问了。使用<code>--user-agent</code>或者<code>-A</code>选项:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL --user-agent <span class="token string">"Mozilla/5.0"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL --user-agent "Mozilla/5.0"
|
||||
curl URL -A "Mozilla/5.0"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL --user-agent <span class="token string">"Mozilla/5.0"</span>
|
||||
<span class="token function">curl</span> URL -A <span class="token string">"Mozilla/5.0"</span>
|
||||
</code></pre>
|
||||
<p>其他HTTP头部信息也可以使用curl来发送,使用<code>-H</code>"头部信息" 传递多个头部信息,例如:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">"Host:wangchujiang.com"</span> -H <span class="token string">"accept-language:zh-cn"</span> URL
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -H "Host:wangchujiang.com" -H "accept-language:zh-cn" URL
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">"Host:wangchujiang.com"</span> -H <span class="token string">"accept-language:zh-cn"</span> URL
|
||||
</code></pre>
|
||||
<p><strong>curl的带宽控制和下载配额</strong></p>
|
||||
<p>使用<code>--limit-rate</code>限制curl的下载速度:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL --limit-rate 50k
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL --limit-rate 50k
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL --limit-rate 50k
|
||||
</code></pre>
|
||||
<p>命令中用k(千字节)和m(兆字节)指定下载速度限制。</p>
|
||||
<p>使用<code>--max-filesize</code>指定可下载的最大文件大小:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL --max-filesize bytes
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL --max-filesize bytes
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL --max-filesize bytes
|
||||
</code></pre>
|
||||
<p>如果文件大小超出限制,命令则返回一个非0退出码,如果命令正常则返回0。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> --limit-rate 200k https://example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl --limit-rate 200k https://example.com
|
||||
# 上面命令将带宽限制在每秒 200K 字节。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> --limit-rate 200k https://example.com
|
||||
<span class="token comment"># 上面命令将带宽限制在每秒 200K 字节。</span>
|
||||
</code></pre>
|
||||
<p><strong>用curl进行认证</strong></p>
|
||||
<p>使用curl选项 -u 可以完成HTTP或者FTP的认证,可以指定密码,也可以不指定密码在后续操作中输入密码:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -u user:pwd http://wangchujiang.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -u user:pwd http://wangchujiang.com
|
||||
curl -u user http://wangchujiang.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -u user:pwd http://wangchujiang.com
|
||||
<span class="token function">curl</span> -u user http://wangchujiang.com
|
||||
</code></pre>
|
||||
<p><strong>只打印响应头部信息</strong></p>
|
||||
<p>通过<code>-I</code>或者<code>-head</code>可以只打印出HTTP头部信息:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># curl -I http://wangchujiang.com</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# curl -I http://wangchujiang.com
|
||||
HTTP/1.1 200 OK
|
||||
Server: nginx/1.2.5
|
||||
date: Mon, 10 Dec 2012 09:24:34 GMT
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Connection: keep-alive
|
||||
Vary: Accept-Encoding
|
||||
X-Pingback: http://wangchujiang.com/xmlrpc.php
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># curl -I http://wangchujiang.com</span>
|
||||
HTTP/1.1 <span class="token number">200</span> OK
|
||||
Server: nginx/1.2.5
|
||||
date: Mon, <span class="token number">10</span> Dec <span class="token number">2012</span> 09:24:34 GMT
|
||||
|
|
@ -610,41 +640,65 @@ Vary: Accept-Encoding
|
|||
X-Pingback: http://wangchujiang.com/xmlrpc.php
|
||||
</code></pre>
|
||||
<p><strong>get请求</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> <span class="token string">"http://www.wangchujiang.com"</span> <span class="token comment"># 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl "http://www.wangchujiang.com" # 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地
|
||||
curl -i "http://www.wangchujiang.com" # 显示全部信息
|
||||
curl -l "http://www.wangchujiang.com" # 只显示头部信息
|
||||
curl -v "http://www.wangchujiang.com" # 显示get请求全过程解析
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> <span class="token string">"http://www.wangchujiang.com"</span> <span class="token comment"># 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地</span>
|
||||
<span class="token function">curl</span> -i <span class="token string">"http://www.wangchujiang.com"</span> <span class="token comment"># 显示全部信息</span>
|
||||
<span class="token function">curl</span> -l <span class="token string">"http://www.wangchujiang.com"</span> <span class="token comment"># 只显示头部信息</span>
|
||||
<span class="token function">curl</span> -v <span class="token string">"http://www.wangchujiang.com"</span> <span class="token comment"># 显示get请求全过程解析</span>
|
||||
</code></pre>
|
||||
<p><strong>post请求</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell">$ <span class="token function">curl</span> -d <span class="token string">"param1=value1&param2=value2"</span> <span class="token string">"http://www.wangchujiang.com/login"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="$ curl -d "param1=value1&param2=value2" "http://www.wangchujiang.com/login"
|
||||
|
||||
curl -d'login=emma&password=123' -X POST https://wangchujiang.com/login
|
||||
# 或者
|
||||
$ curl -d 'login=emma' -d 'password=123' -X POST https://wangchujiang.com/login
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">$ <span class="token function">curl</span> -d <span class="token string">"param1=value1&param2=value2"</span> <span class="token string">"http://www.wangchujiang.com/login"</span>
|
||||
|
||||
<span class="token function">curl</span> -d<span class="token string">'login=emma&password=123'</span> -X POST https://wangchujiang.com/login
|
||||
<span class="token comment"># 或者</span>
|
||||
$ <span class="token function">curl</span> -d <span class="token string">'login=emma'</span> -d <span class="token string">'password=123'</span> -X POST https://wangchujiang.com/login
|
||||
</code></pre>
|
||||
<p><code>--data-urlencode</code> 参数等同于 <code>-d</code>,发送 <code>POST</code> 请求的数据体,区别在于会自动将发送的数据进行 <code>URL</code> 编码。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> --data-urlencode <span class="token string">'comment=hello world'</span> https://wangchujiang.com/login
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl --data-urlencode 'comment=hello world' https://wangchujiang.com/login
|
||||
# 上面代码中,发送的数据hello world之间有一个空格,需要进行 URL 编码。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> --data-urlencode <span class="token string">'comment=hello world'</span> https://wangchujiang.com/login
|
||||
<span class="token comment"># 上面代码中,发送的数据hello world之间有一个空格,需要进行 URL 编码。</span>
|
||||
</code></pre>
|
||||
<p><strong>读取本地文本文件的数据,向服务器发送</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -d <span class="token string">'@data.txt'</span> https://wangchujiang.com/upload
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -d '@data.txt' https://wangchujiang.com/upload
|
||||
# 读取data.txt文件的内容,作为数据体向服务器发送。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -d <span class="token string">'@data.txt'</span> https://wangchujiang.com/upload
|
||||
<span class="token comment"># 读取data.txt文件的内容,作为数据体向服务器发送。</span>
|
||||
</code></pre>
|
||||
<p><strong>json格式的post请求</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -l -H <span class="token string">"Content-type: application/json"</span> -X POST -d <span class="token string">'{"phone":"13521389587","password":"test"}'</span> http://wangchujiang.com/apis/users.json
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -l -H "Content-type: application/json" -X POST -d '{"phone":"13521389587","password":"test"}' http://wangchujiang.com/apis/users.json
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -l -H <span class="token string">"Content-type: application/json"</span> -X POST -d <span class="token string">'{"phone":"13521389587","password":"test"}'</span> http://wangchujiang.com/apis/users.json
|
||||
</code></pre>
|
||||
<p><strong>向服务器发送 Cookie</strong></p>
|
||||
<p>使用<code>--cookie "COKKIES"</code>选项来指定cookie,多个cookie使用分号分隔:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> http://wangchujiang.com --cookie <span class="token string">"user=root;pass=123456"</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl http://wangchujiang.com --cookie "user=root;pass=123456"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> http://wangchujiang.com --cookie <span class="token string">"user=root;pass=123456"</span>
|
||||
</code></pre>
|
||||
<p>将cookie另存为一个文件,使用<code>--cookie-jar</code>选项:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> URL --cookie-jar cookie_file
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl URL --cookie-jar cookie_file
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> URL --cookie-jar cookie_file
|
||||
</code></pre>
|
||||
<p><code>-b</code> 参数用来向服务器发送 Cookie。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -b <span class="token string">'foo=bar'</span> https://taobao.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -b 'foo=bar' https://taobao.com
|
||||
# 上面命令会生成一个标头Cookie: foo=bar,向服务器发送一个名为foo、值为bar的 Cookie。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -b <span class="token string">'foo=bar'</span> https://taobao.com
|
||||
<span class="token comment"># 上面命令会生成一个标头Cookie: foo=bar,向服务器发送一个名为foo、值为bar的 Cookie。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -b <span class="token string">'foo1=bar'</span> -b <span class="token string">'foo2=baz'</span> https://taobao.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -b 'foo1=bar' -b 'foo2=baz' https://taobao.com
|
||||
# 上面命令发送两个 Cookie。
|
||||
|
||||
```shell
|
||||
curl -b cookies.txt https://www.taobao.com
|
||||
# 上面命令读取本地文件 cookies.txt,里面是服务器设置的 Cookie(参见-c参数),将其发送到服务器。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -b <span class="token string">'foo1=bar'</span> -b <span class="token string">'foo2=baz'</span> https://taobao.com
|
||||
<span class="token comment"># 上面命令发送两个 Cookie。</span>
|
||||
|
||||
```shell
|
||||
|
|
@ -652,63 +706,96 @@ $ <span class="token function">curl</span> -d <span class="token string">'login=
|
|||
<span class="token comment"># 上面命令读取本地文件 cookies.txt,里面是服务器设置的 Cookie(参见-c参数),将其发送到服务器。</span>
|
||||
</code></pre>
|
||||
<p><strong>Cookie 写入一个文件</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -c cookies.txt https://www.taobao.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -c cookies.txt https://www.taobao.com
|
||||
# 上面命令将服务器的 HTTP 回应所设置 Cookie 写入文本文件cookies.txt。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -c cookies.txt https://www.taobao.com
|
||||
<span class="token comment"># 上面命令将服务器的 HTTP 回应所设置 Cookie 写入文本文件cookies.txt。</span>
|
||||
</code></pre>
|
||||
<p><strong>请求的来源</strong></p>
|
||||
<p><code>-e</code> 参数用来设置 <code>HTTP</code> 的标头 <code>Referer</code>,表示请求的来源。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -e <span class="token string">'https://taobao.com?q=example'</span> https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -e 'https://taobao.com?q=example' https://www.example.com
|
||||
# 上面命令将Referer标头设为 https://taobao.com?q=example。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -e <span class="token string">'https://taobao.com?q=example'</span> https://www.example.com
|
||||
<span class="token comment"># 上面命令将Referer标头设为 https://taobao.com?q=example。</span>
|
||||
</code></pre>
|
||||
<p><code>-H</code> 参数可以通过直接添加标头 <code>Referer</code>,达到同样效果。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Referer: https://taobao.com?q=example'</span> https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -H 'Referer: https://taobao.com?q=example' https://www.example.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Referer: https://taobao.com?q=example'</span> https://www.example.com
|
||||
</code></pre>
|
||||
<p><strong>上传二进制文件</strong></p>
|
||||
<p><code>-F</code> 参数用来向服务器上传二进制文件。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png'</span> https://taobao.com/profile
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -F 'file=@photo.png' https://taobao.com/profile
|
||||
# 上面命令会给 HTTP 请求加上标头 Content-Type: multipart/form-data ,然后将文件photo.png作为file字段上传。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png'</span> https://taobao.com/profile
|
||||
<span class="token comment"># 上面命令会给 HTTP 请求加上标头 Content-Type: multipart/form-data ,然后将文件photo.png作为file字段上传。</span>
|
||||
</code></pre>
|
||||
<p><code>-F</code> 参数可以指定 <code>MIME</code> 类型。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png;type=image/png'</span> https://taobao.com/profile
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -F 'file=@photo.png;type=image/png' https://taobao.com/profile
|
||||
# 上面命令指定 MIME 类型为image/png,否则 curl 会把 MIME 类型设为 application/octet-stream。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png;type=image/png'</span> https://taobao.com/profile
|
||||
<span class="token comment"># 上面命令指定 MIME 类型为image/png,否则 curl 会把 MIME 类型设为 application/octet-stream。</span>
|
||||
</code></pre>
|
||||
<p><code>-F</code> 参数也可以指定文件名。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png;filename=me.png'</span> https://taobao.com/profile
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -F 'file=@photo.png;filename=me.png' https://taobao.com/profile
|
||||
# 上面命令中,原始文件名为photo.png,但是服务器接收到的文件名为me.png。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -F <span class="token string">'file=@photo.png;filename=me.png'</span> https://taobao.com/profile
|
||||
<span class="token comment"># 上面命令中,原始文件名为photo.png,但是服务器接收到的文件名为me.png。</span>
|
||||
</code></pre>
|
||||
<p><strong>设置请求头</strong></p>
|
||||
<p><code>-H</code> 参数添加 <code>HTTP</code> 请求的标头。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Accept-Language: en-US'</span> https://google.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -H 'Accept-Language: en-US' https://google.com
|
||||
# 上面命令添加 HTTP 标头 Accept-Language: en-US。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Accept-Language: en-US'</span> https://google.com
|
||||
<span class="token comment"># 上面命令添加 HTTP 标头 Accept-Language: en-US。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Accept-Language: en-US'</span> -H <span class="token string">'Secret-Message: xyzzy'</span> https://google.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://google.com
|
||||
# 上面命令添加两个 HTTP 标头。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -H <span class="token string">'Accept-Language: en-US'</span> -H <span class="token string">'Secret-Message: xyzzy'</span> https://google.com
|
||||
<span class="token comment"># 上面命令添加两个 HTTP 标头。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -d <span class="token string">'{"login": "emma", "pass": "123"}'</span> -H <span class="token string">'Content-Type: application/json'</span> https://google.com/login
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -d '{"login": "emma", "pass": "123"}' -H 'Content-Type: application/json' https://google.com/login
|
||||
# 上面命令添加 HTTP 请求的标头是 Content-Type: application/json,然后用 -d 参数发送 JSON 数据。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -d <span class="token string">'{"login": "emma", "pass": "123"}'</span> -H <span class="token string">'Content-Type: application/json'</span> https://google.com/login
|
||||
<span class="token comment"># 上面命令添加 HTTP 请求的标头是 Content-Type: application/json,然后用 -d 参数发送 JSON 数据。</span>
|
||||
</code></pre>
|
||||
<p><strong>跳过 SSL 检测</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -k https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -k https://www.example.com
|
||||
# 上面命令不会检查服务器的 SSL 证书是否正确。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -k https://www.example.com
|
||||
<span class="token comment"># 上面命令不会检查服务器的 SSL 证书是否正确。</span>
|
||||
</code></pre>
|
||||
<p><strong>请求跟随服务器的重定向</strong></p>
|
||||
<p><code>-L</code> 参数会让 <code>HTTP</code> 请求跟随服务器的重定向。<code>curl</code> 默认不跟随重定向。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -L -d <span class="token string">'tweet=hi'</span> https://api.example.com/tweet
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -L -d 'tweet=hi' https://api.example.com/tweet
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -L -d <span class="token string">'tweet=hi'</span> https://api.example.com/tweet
|
||||
</code></pre>
|
||||
<p><strong>调试参数</strong></p>
|
||||
<p><code>-v</code> 参数输出通信的整个过程,用于调试。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> -v https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl -v https://www.example.com
|
||||
# --trace参数也可以用于调试,还会输出原始的二进制数据。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> -v https://www.example.com
|
||||
<span class="token comment"># --trace参数也可以用于调试,还会输出原始的二进制数据。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell">$ <span class="token function">curl</span> --trace - https://www.example.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="$ curl --trace - https://www.example.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">$ <span class="token function">curl</span> --trace - https://www.example.com
|
||||
</code></pre>
|
||||
<p><strong>获取本机外网ip</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">curl</span> ipecho.net/plain
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="curl ipecho.net/plain
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">curl</span> ipecho.net/plain
|
||||
</code></pre>
|
||||
<p><strong>使用 curl 测试网站加载速度</strong></p>
|
||||
<p>命令有一个鲜为人知的选项,<code>-w</code>,该选项在请求结束之后打印本次请求的统计数据到标准输出。</p>
|
||||
<p>首先,我们定义控制打印行为的格式化字符串。新建文本文件 <code>fmt.txt</code>,并填入下面的内容:</p>
|
||||
<pre class="language-ruby"><code class="language-ruby">\n
|
||||
<pre class="language-ruby"><div onclick="copied(this)" data-code="\n
|
||||
Response Time for: %{url_effective}\n\n
|
||||
DNS Lookup Time:\t\t%{time_namelookup}s\n
|
||||
Redirection Time:\t\t%{time_redirect}s\n
|
||||
Connection Time:\t\t%{time_connect}s\n
|
||||
App Connection Time:\t\t%{time_appconnect}s\n
|
||||
Pre-transfer Time:\t\t%{time_pretransfer}s\n
|
||||
Start-transfer Time:\t\t%{time_starttransfer}s\n\n
|
||||
Total Time:\t\t\t%{time_total}s\n
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-ruby">\n
|
||||
<span class="token constant">Response</span> <span class="token builtin">Time</span> <span class="token keyword">for</span><span class="token punctuation">:</span> <span class="token string">%{url_effective}</span>\n\n
|
||||
<span class="token constant">DNS</span> <span class="token constant">Lookup</span> <span class="token builtin">Time</span><span class="token punctuation">:</span>\t\t<span class="token string">%{time_namelookup}</span>s\n
|
||||
<span class="token constant">Redirection</span> <span class="token builtin">Time</span><span class="token punctuation">:</span>\t\t<span class="token string">%{time_redirect}</span>s\n
|
||||
|
|
@ -730,10 +817,21 @@ $ <span class="token function">curl</span> -d <span class="token string">'login=
|
|||
<li><code>time_total</code>: 完整耗时。</li>
|
||||
</ul>
|
||||
<p>然后执行请求,通过 @filename 指定保存了格式化字符串的文件:</p>
|
||||
<pre class="language-shell"><code class="language-shell">$ <span class="token function">curl</span> -L -s -w @fmt.txt -o /dev/null http://www.google.com
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="$ curl -L -s -w @fmt.txt -o /dev/null http://www.google.com
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">$ <span class="token function">curl</span> -L -s -w @fmt.txt -o /dev/null http://www.google.com
|
||||
</code></pre>
|
||||
<p>输出:</p>
|
||||
<pre class="language-c"><code class="language-c">Response Time <span class="token keyword">for</span><span class="token operator">:</span> http<span class="token operator">:</span><span class="token comment">//www.google.co.jp/?gfe_rd=cr&dcr=0&ei=cjIaWpTkHeiQ8QfnxYzoBA</span>
|
||||
<pre class="language-c"><div onclick="copied(this)" data-code="Response Time for: http://www.google.co.jp/?gfe_rd=cr&dcr=0&ei=cjIaWpTkHeiQ8QfnxYzoBA
|
||||
|
||||
DNS Lookup Time: 0.000038s
|
||||
Redirection Time: 0.207271s
|
||||
Connection Time: 0.000039s
|
||||
App Connection Time: 0.000039s
|
||||
Pre-transfer Time: 0.000067s
|
||||
Start-transfer Time: 0.260115s
|
||||
|
||||
Total Time: 0.467691s
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-c">Response Time <span class="token keyword">for</span><span class="token operator">:</span> http<span class="token operator">:</span><span class="token comment">//www.google.co.jp/?gfe_rd=cr&dcr=0&ei=cjIaWpTkHeiQ8QfnxYzoBA</span>
|
||||
|
||||
DNS Lookup Time<span class="token operator">:</span> <span class="token number">0.000038</span>s
|
||||
Redirection Time<span class="token operator">:</span> <span class="token number">0.207271</span>s
|
||||
|
|
@ -745,7 +843,28 @@ Start<span class="token operator">-</span>transfer Time<span class="token operat
|
|||
Total Time<span class="token operator">:</span> <span class="token number">0.467691</span>s
|
||||
</code></pre>
|
||||
<h3 id="要求返回是压缩的状态"><a class="anchor" aria-hidden="true" tabindex="-1" href="#要求返回是压缩的状态"><span class="octicon octicon-link"></span></a>要求返回是压缩的状态</h3>
|
||||
<pre class="language-shell"><code class="language-shell">▶ <span class="token function">curl</span> --compressed -o- -L https://yarnpkg.com/install.sh <span class="token operator">|</span> <span class="token function">bash</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="▶ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
|
||||
% Total % Received % Xferd Average Speed Time Time Time Current
|
||||
Dload Upload Total Spent Left Speed
|
||||
100 54 100 54 0 0 42 0 0:00:01 0:00:01 --:--:-- 42
|
||||
100 2341 100 2341 0 0 1202 0 0:00:01 0:00:01 --:--:-- 9289
|
||||
Installing Yarn!
|
||||
> Downloading tarball...
|
||||
|
||||
[1/2]: https://yarnpkg.com/latest.tar.gz --> /var/folders/j7/3xly5sk567s65ny5dnr__3b80000gn/T/yarn.tar.gz.XXXXXXXXXX.9hJsBsrA
|
||||
% Total % Received % Xferd Average Speed Time Time Time Current
|
||||
Dload Upload Total Spent Left Speed
|
||||
100 57 100 57 0 0 72 0 --:--:-- --:--:-- --:--:-- 72
|
||||
100 93 100 93 0 0 63 0 0:00:01 0:00:01 --:--:-- 63
|
||||
100 643 100 643 0 0 248 0 0:00:02 0:00:02 --:--:-- 707
|
||||
100 1215k 100 1215k 0 0 153k 0 0:00:07 0:00:07 --:--:-- 305k
|
||||
|
||||
[2/2]: https://yarnpkg.com/latest.tar.gz.asc --> /var/folders/j7/3xly5sk567s65ny5dnr__3b80000gn/T/yarn.tar.gz.XXXXXXXXXX.9hJsBsrA.asc
|
||||
100 61 100 61 0 0 356 0 --:--:-- --:--:-- --:--:-- 356
|
||||
100 97 100 97 0 0 325 0 --:--:-- --:--:-- --:--:-- 325
|
||||
100 647 100 647 0 0 1283 0 --:--:-- --:--:-- --:--:-- 1283
|
||||
100 832 100 832 0 0 1107 0 --:--:-- --:--:-- --:--:-- 812k
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">▶ <span class="token function">curl</span> --compressed -o- -L https://yarnpkg.com/install.sh <span class="token operator">|</span> <span class="token function">bash</span>
|
||||
% Total % Received % Xferd Average Speed Time Time Time Current
|
||||
Dload Upload Total Spent Left Speed
|
||||
<span class="token number">100</span> <span class="token number">54</span> <span class="token number">100</span> <span class="token number">54</span> <span class="token number">0</span> <span class="token number">0</span> <span class="token number">42</span> <span class="token number">0</span> <span class="token number">0</span>:00:01 <span class="token number">0</span>:00:01 --:--:-- <span class="token number">42</span>
|
||||
|
|
@ -792,7 +911,7 @@ Installing Yarn<span class="token operator">!</span>
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199576"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199576"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220800"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220800"></script>
|
||||
</body>
|
||||
</html>
|
||||
100
c/cut.html
100
c/cut.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,cut,连接文件并打印到标准输出设备上">
|
||||
<title>cut 命令,Linux cut 命令详解:连接文件并打印到标准输出设备上 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199610">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220827">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -59,10 +59,20 @@
|
|||
<p>说明:该命令有两项功能,其一是用来显示文件的内容,它依次读取由参数 file 所指 明的文件,将它们的内容输出到标准输出上;其二是连接两个或多个文件,如<code>cut fl f2 > f3</code>将把文件 fl 和 f2 的内容合并起来,然后通过输出重定向符“>”的作用,将它们放入文件 f3 中。</p>
|
||||
<p>当文件较大时,文本在屏幕上迅速闪过(滚屏),用户往往看不清所显示的内容。因此,一般用 more 等命令分屏显示。为了控制滚屏,可以按 Ctrl+S 键,停止滚屏;按 Ctrl+Q 键可以恢复滚屏。按 Ctrl+C(中断)键可以终止该命令的执行,并且返回 Shell 提示符状态。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">cut(选项)(参数)
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cut(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">cut(选项)(参数)
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b:仅显示行中指定直接范围的内容;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b:仅显示行中指定直接范围的内容;
|
||||
-c:仅显示行中指定范围的字符;
|
||||
-d:指定字段的分隔符,默认的字段分隔符为“TAB”;
|
||||
-f:显示指定字段的内容;
|
||||
-n:与“-b”选项连用,不分割多字节字符;
|
||||
--complement:补足被选择的字节、字符或字段;
|
||||
--out-delimiter= 字段分隔符:指定输出内容是的字段分割符;
|
||||
--help:显示指令的帮助信息;
|
||||
--version:显示指令的版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b:仅显示行中指定直接范围的内容;
|
||||
-c:仅显示行中指定范围的字符;
|
||||
-d:指定字段的分隔符,默认的字段分隔符为“TAB”;
|
||||
-f:显示指定字段的内容;
|
||||
|
|
@ -76,7 +86,13 @@
|
|||
<p>文件:指定要进行内容过滤的文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>例如有一个学生报表信息,包含 No、Name、Mark、Percent:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cat test.txt
|
||||
No Name Mark Percent
|
||||
01 tom 69 91
|
||||
02 jack 71 87
|
||||
03 alex 68 98
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test.txt</span>
|
||||
No Name Mark Percent
|
||||
01 tom <span class="token number">69</span> <span class="token number">91</span>
|
||||
02 jack <span class="token number">71</span> <span class="token number">87</span>
|
||||
|
|
@ -84,13 +100,24 @@ No Name Mark Percent
|
|||
|
||||
</code></pre>
|
||||
<p>使用 <strong>-f</strong> 选项提取指定字段(这里的 f 参数可以简单记忆为 <code>--fields</code>的缩写):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f 1 test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -f 1 test.txt
|
||||
No
|
||||
01
|
||||
02
|
||||
03
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f 1 test.txt</span>
|
||||
No
|
||||
01
|
||||
02
|
||||
03
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2,3 test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -f2,3 test.txt
|
||||
Name Mark
|
||||
tom 69
|
||||
jack 71
|
||||
alex 68
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2,3 test.txt</span>
|
||||
Name Mark
|
||||
tom <span class="token number">69</span>
|
||||
jack <span class="token number">71</span>
|
||||
|
|
@ -98,20 +125,36 @@ alex <span class="token number">68</span>
|
|||
|
||||
</code></pre>
|
||||
<p><strong>--complement</strong> 选项提取指定字段之外的列(打印除了第二列之外的列):</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2 --complement test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -f2 --complement test.txt
|
||||
No Mark Percent
|
||||
01 69 91
|
||||
02 71 87
|
||||
03 68 98
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2 --complement test.txt</span>
|
||||
No Mark Percent
|
||||
01 <span class="token number">69</span> <span class="token number">91</span>
|
||||
02 <span class="token number">71</span> <span class="token number">87</span>
|
||||
03 <span class="token number">68</span> <span class="token number">98</span>
|
||||
</code></pre>
|
||||
<p>使用 <strong>-d</strong> 选项指定字段分隔符:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test2.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cat test2.txt
|
||||
No;Name;Mark;Percent
|
||||
01;tom;69;91
|
||||
02;jack;71;87
|
||||
03;alex;68;98
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test2.txt</span>
|
||||
No<span class="token punctuation">;</span>Name<span class="token punctuation">;</span>Mark<span class="token punctuation">;</span>Percent
|
||||
01<span class="token punctuation">;</span>tom<span class="token punctuation">;</span><span class="token number">69</span><span class="token punctuation">;</span><span class="token number">91</span>
|
||||
02<span class="token punctuation">;</span>jack<span class="token punctuation">;</span><span class="token number">71</span><span class="token punctuation">;</span><span class="token number">87</span>
|
||||
03<span class="token punctuation">;</span>alex<span class="token punctuation">;</span><span class="token number">68</span><span class="token punctuation">;</span><span class="token number">98</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2 -d";" test2.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -f2 -d";" test2.txt
|
||||
Name
|
||||
tom
|
||||
jack
|
||||
alex
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -f2 -d";" test2.txt</span>
|
||||
Name
|
||||
tom
|
||||
jack
|
||||
|
|
@ -132,7 +175,14 @@ alex
|
|||
<li><strong>-f</strong> 表示定义字段。</li>
|
||||
</ul>
|
||||
<p><strong>示例</strong></p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cat test.txt
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cat test.txt</span>
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
|
|
@ -141,7 +191,14 @@ abcdefghijklmnopqrstuvwxyz
|
|||
|
||||
</code></pre>
|
||||
<p>打印第 1 个到第 3 个字符:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c1-3 test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -c1-3 test.txt
|
||||
abc
|
||||
abc
|
||||
abc
|
||||
abc
|
||||
abc
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c1-3 test.txt</span>
|
||||
abc
|
||||
abc
|
||||
abc
|
||||
|
|
@ -150,7 +207,14 @@ abc
|
|||
|
||||
</code></pre>
|
||||
<p>打印前 2 个字符:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c-2 test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -c-2 test.txt
|
||||
ab
|
||||
ab
|
||||
ab
|
||||
ab
|
||||
ab
|
||||
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c-2 test.txt</span>
|
||||
ab
|
||||
ab
|
||||
ab
|
||||
|
|
@ -159,7 +223,13 @@ ab
|
|||
|
||||
</code></pre>
|
||||
<p>打印从第 5 个字符开始到结尾:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c5- test.txt</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# cut -c5- test.txt
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># cut -c5- test.txt</span>
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
|
|
@ -191,7 +261,7 @@ efghijklmnopqrstuvwxyz
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199611"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199611"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220827"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220827"></script>
|
||||
</body>
|
||||
</html>
|
||||
158
c/date.html
158
c/date.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,date,显示或设置系统时间与日期">
|
||||
<title>date 命令,Linux date 命令详解:显示或设置系统时间与日期 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199641">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220851">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,9 @@
|
|||
<h1 id="date"><a class="anchor" aria-hidden="true" tabindex="-1" href="#date"><span class="octicon octicon-link"></span></a>date</h1>
|
||||
<p>显示或设置系统时间与日期</p>
|
||||
<h2 id="概要"><a class="anchor" aria-hidden="true" tabindex="-1" href="#概要"><span class="octicon octicon-link"></span></a>概要</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">date</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>+FORMAT<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="date [OPTION]... [+FORMAT]
|
||||
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">date</span> <span class="token punctuation">[</span>OPTION<span class="token punctuation">]</span><span class="token punctuation">..</span>. <span class="token punctuation">[</span>+FORMAT<span class="token punctuation">]</span>
|
||||
<span class="token function">date</span> <span class="token punctuation">[</span>-u<span class="token operator">|</span>--utc<span class="token operator">|</span>--universal<span class="token punctuation">]</span> <span class="token punctuation">[</span>MMDDhhmm<span class="token punctuation">[</span><span class="token punctuation">[</span>CC<span class="token punctuation">]</span>YY<span class="token punctuation">]</span><span class="token punctuation">[</span>.ss<span class="token punctuation">]</span><span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
|
|
@ -65,7 +67,67 @@
|
|||
</ul>
|
||||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<p>format:输出的时间格式。</p>
|
||||
<pre class="language-shell"><code class="language-shell">format可用的转义序列如下:
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="format可用的转义序列如下:
|
||||
|
||||
%% 百分号
|
||||
%a 当地缩写的工作日名称(例如,Sun)
|
||||
%A 当地完整的工作日名称(例如,Sunday)
|
||||
%b 当地缩写的月份名称(例如,Jan)
|
||||
%B 当地完整的月份名称(例如,January)
|
||||
%c 当地的日期和时间(例如,Thu Mar 3 23:05:25 2005)
|
||||
%C 世纪,和%Y类似,但是省略后两位(例如,20)
|
||||
%d 一月中的一天(例如,01)
|
||||
%D 日期,等价于%m/%d/%y
|
||||
%e 一月中的一天,格式使用空格填充,等价于%_d
|
||||
%F 完整的日期;等价于%+4Y-%m-%d
|
||||
%g ISO标准计数周的年份的最后两位数字
|
||||
%G ISO标准计数周的年份,通常只对%V有用
|
||||
%h 等价于%b
|
||||
%H 小时,范围(00..23)
|
||||
%I 小时,范围(00..23)
|
||||
%j 一年中的一天,范围(001..366)
|
||||
%k 小时,使用空格填充,范围(0..23),等价于%_H
|
||||
%l 小时,使用空格填充,范围(1..12),等价于%_I
|
||||
%m 月,范围(01..12)
|
||||
%M 分钟,范围(00..59)
|
||||
%n 换行符
|
||||
%N 纳秒,范围(000000000..000000000)
|
||||
%p 用于表示当地的AM或PM,如果未知则为空白
|
||||
%P 类似于%p,但用小写表示
|
||||
%q 季度,范围(1..4)
|
||||
%r 当地以12小时表示的时钟时间(例如,11:11:04 PM)
|
||||
%R 24小时每分钟;等价于%H:%M
|
||||
%s 自协调世界时1970年01月01日00时00分以来的秒数
|
||||
%S 秒数,范围(00..60)
|
||||
%t 水平制表符
|
||||
%T 时间;等价于%H:%M:%S
|
||||
%u 一周中的一天(1..7),1代表星期一
|
||||
%U 一年中的第几周,周日作为一周的起始(00..53)
|
||||
%V ISO标准计数周,该方法将周一作为一周的起始(01..53)
|
||||
%w 一周中的一天(0..6),0代表星期天
|
||||
%W 一年中的第几周,周一作为一周的起始(00..53)
|
||||
%x 当地的日期表示(例如,12/31/99)
|
||||
%X 当地的时间表示(例如,23:13:48)
|
||||
%y 年份后两位数字,范围(00..99)
|
||||
%Y 年份
|
||||
%z +hhmm格式的数值化时区格式(例如,-0400)
|
||||
%:z +hh:mm格式的数值化时区格式(例如,-04:00)
|
||||
%::z +hh:mm:ss格式的数值化时区格式(例如,-04:00:00)
|
||||
%:::z 数值化时区格式,相比上一个格式增加':'以显示必要的精度(例如,-04,+05:30)
|
||||
%Z 时区缩写(如EDT)
|
||||
|
||||
默认情况下,日期用零填充数字字段;以下可选的符号可以跟在'%'后面:
|
||||
|
||||
- (连字符) 不要填充相应的字段。
|
||||
_ (下划线) 使用空格填充相应的字段。
|
||||
0 (数字0) 使用数字0填充相应的字段。
|
||||
+ 用数字0填充,未来年份大于4位数字则在前面加上'+'号。
|
||||
^ 允许的情况下使用大写。
|
||||
# 允许的情况下将默认的大写转换为小写,默认的小写转换为大写。
|
||||
|
||||
在任何标志之后都有一个可选的字段宽度,如小数;然后是一个可选的修饰符,在可用的情况下,使用E来使用当地语言环境的替代表示,
|
||||
使用O来使用当地语言环境的替代数字符号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">format可用的转义序列如下:
|
||||
|
||||
%% 百分号
|
||||
%a 当地缩写的工作日名称(例如,Sun)
|
||||
|
|
@ -127,7 +189,22 @@ _ <span class="token punctuation">(</span>下划线<span class="token punct
|
|||
使用O来使用当地语言环境的替代数字符号。
|
||||
</code></pre>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">长选项与短选项等价
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="长选项与短选项等价
|
||||
|
||||
-d, --date=STRING 解析字符串并按照指定格式输出,字符串不能是'now'。
|
||||
--debug 注释已解析的日期,并将有疑问的用法发送到标准错误。
|
||||
-f, --file=DATEFILE 类似于--date; 一次从DATEFILE处理一行。
|
||||
-I[FMT], --iso-8601[=FMT] 按照ISO 8601格式输出,FMT可以为'date'(默认),'hours','minutes','seconds','ns'。
|
||||
例如:2006-08-14T02:34:56-06:00
|
||||
-R, --rfc-email 按照RFC 5322格式输出,例如: Mon, 14 Aug 2006 02:34:56 -0600
|
||||
--rfc-3339=FMT 按照RFC 3339格式输出,FMT可以为'date', 'seconds','ns'中的一个,
|
||||
例如:2006-08-14 02:34:56-06:00
|
||||
-r, --reference=FILE 显示文件的上次修改时间。
|
||||
-s, --set=STRING 根据字符串设置系统时间。
|
||||
-u, --utc, --universal 显示或设置世界协调时(UTC)。
|
||||
--help 显示帮助信息并退出。
|
||||
--version 显示版本信息并退出。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">长选项与短选项等价
|
||||
|
||||
-d, --date<span class="token operator">=</span>STRING 解析字符串并按照指定格式输出,字符串不能是<span class="token string">'now'</span>。
|
||||
--debug 注释已解析的日期,并将有疑问的用法发送到标准错误。
|
||||
|
|
@ -146,7 +223,74 @@ _ <span class="token punctuation">(</span>下划线<span class="token punct
|
|||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>返回状态为成功除非给出了非法选项或非法参数。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 格式化输出:</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 格式化输出:
|
||||
date +"%Y-%m-%d"
|
||||
2009-12-07
|
||||
|
||||
# 输出昨天日期:
|
||||
date -d "1 day ago" +"%Y-%m-%d"
|
||||
2012-11-19
|
||||
|
||||
# 2秒后输出:
|
||||
date -d "2 second" +"%Y-%m-%d %H:%M.%S"
|
||||
2012-11-20 14:21.31
|
||||
|
||||
# 传说中的 1234567890 秒:
|
||||
date -d "1970-01-01 1234567890 seconds" +"%Y-%m-%d %H:%M:%S"
|
||||
# 或者
|
||||
date -d@1234567890 +"%F %T"
|
||||
# 输出结果
|
||||
2009-02-13 23:02:30
|
||||
|
||||
# 时间格式转换:
|
||||
date -d "2009-12-12" +"%Y/%m/%d %H:%M.%S"
|
||||
# 输出结果
|
||||
2009/12/12 00:00.00
|
||||
|
||||
# apache格式转换:
|
||||
date -d "Dec 5, 2009 12:00:37 AM" +"%Y-%m-%d %H:%M.%S"
|
||||
# 输出结果
|
||||
2009-12-05 00:00.37
|
||||
|
||||
# 格式转换后时间游走:
|
||||
date -d "Dec 5, 2009 12:00:37 AM 2 year ago" +"%Y-%m-%d %H:%M.%S"
|
||||
# 输出结果
|
||||
2007-12-05 00:00.37
|
||||
|
||||
# 时间加减操作:
|
||||
date +%Y%m%d # 显示年月日
|
||||
date -d "+1 day" +%Y%m%d # 显示前一天的日期
|
||||
date -d "-1 day" +%Y%m%d # 显示后一天的日期
|
||||
date -d "-1 month" +%Y%m%d # 显示上一月的日期
|
||||
date -d "+1 month" +%Y%m%d # 显示下一月的日期
|
||||
date -d "-1 year" +%Y%m%d # 显示前一年的日期
|
||||
date -d "+1 year" +%Y%m%d # 显示下一年的日期
|
||||
|
||||
# 设定时间:
|
||||
date -s # 设置当前时间,只有root权限才能设置,其他只能查看
|
||||
date -s 20120523 # 设置成20120523,这样会把具体时间设置成00:00:00
|
||||
date -s 01:01:01 # 设置具体时间,不会对日期做更改
|
||||
date -s "01:01:01 2012-05-23" # 这样可以设置全部时间
|
||||
date -s "01:01:01 20120523" # 这样可以设置全部时间
|
||||
date -s "2012-05-23 01:01:01" # 这样可以设置全部时间
|
||||
date -s "20120523 01:01:01" # 这样可以设置全部时间
|
||||
|
||||
# 有时需要检查一组命令花费的时间:
|
||||
start=$(date +%s)
|
||||
nmap wangchujiang.com &> /dev/null
|
||||
end=$(date +%s)
|
||||
difference=$(( end - start ))
|
||||
# 显示执行时间
|
||||
echo $difference seconds.
|
||||
|
||||
# 当你考虑输出带有时间的字符串时,例如(Current time: 2019/05/19):
|
||||
# 通常使用的方法:
|
||||
echo "Current time: $(date +"%Y/%m/%d")"
|
||||
# 另一种方法:
|
||||
suffix='Current time:'
|
||||
# 注意如果换成单引号就不能替换变量了。
|
||||
date +"${suffix} %Y/%m/%d"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 格式化输出:</span>
|
||||
<span class="token function">date</span> +<span class="token string">"%Y-%m-%d"</span>
|
||||
<span class="token number">2009</span>-12-07
|
||||
|
||||
|
|
@ -243,7 +387,7 @@ nmap wangchujiang.com <span class="token operator">&></span> /dev/null
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199642"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199642"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220851"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220851"></script>
|
||||
</body>
|
||||
</html>
|
||||
41
c/dd.html
41
c/dd.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dd,复制文件并对原文件的内容进行转换和格式化处理">
|
||||
<title>dd 命令,Linux dd 命令详解:复制文件并对原文件的内容进行转换和格式化处理 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199676">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220881">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -58,10 +58,22 @@
|
|||
<p><strong>dd命令</strong> 用于复制文件并对原文件的内容进行转换和格式化处理。dd命令功能很强大的,对于一些比较底层的问题,使用dd命令往往可以得到出人意料的效果。用的比较多的还是用dd来备份裸设备。但是不推荐,如果需要备份oracle裸设备,可以使用rman备份,或使用第三方软件备份,使用dd的话,管理起来不太方便。</p>
|
||||
<p>建议在有需要的时候使用dd 对物理磁盘操作,如果是文件系统的话还是使用tar backup cpio等其他命令更加方便。另外,使用dd对磁盘操作时,最好使用块设备文件。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dd(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dd<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token assign-left variable">bs</span><span class="token operator">=</span><span class="token operator"><</span>字节数<span class="token operator">></span>:将ibs(输入)与obs(输出)设成指定的字节数;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="bs=<字节数>:将ibs(输入)与obs(输出)设成指定的字节数;
|
||||
cbs=<字节数>:转换时,每次只转换指定的字节数;
|
||||
conv=<关键字>:指定文件转换的方式;
|
||||
count=<区块数>:仅读取指定的区块数;
|
||||
ibs=<字节数>:每次读取的字节数;
|
||||
obs=<字节数>:每次输出的字节数;
|
||||
of=<文件>:输出到文件;
|
||||
seek=<区块数>:一开始输出时,跳过指定的区块数;
|
||||
skip=<区块数>:一开始读取时,跳过指定的区块数;
|
||||
--help:帮助;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token assign-left variable">bs</span><span class="token operator">=</span><span class="token operator"><</span>字节数<span class="token operator">></span>:将ibs(输入)与obs(输出)设成指定的字节数;
|
||||
<span class="token assign-left variable">cbs</span><span class="token operator">=</span><span class="token operator"><</span>字节数<span class="token operator">></span>:转换时,每次只转换指定的字节数;
|
||||
<span class="token assign-left variable">conv</span><span class="token operator">=</span><span class="token operator"><</span>关键字<span class="token operator">></span>:指定文件转换的方式;
|
||||
<span class="token assign-left variable">count</span><span class="token operator">=</span><span class="token operator"><</span>区块数<span class="token operator">></span>:仅读取指定的区块数;
|
||||
|
|
@ -74,7 +86,14 @@
|
|||
--version:显示版本信息。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># dd if=/dev/zero of=sun.txt bs=1M count=1</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost text]# dd if=/dev/zero of=sun.txt bs=1M count=1
|
||||
1+0 records in
|
||||
1+0 records out
|
||||
1048576 bytes (1.0 MB) copied, 0.006107 seconds, 172 MB/s
|
||||
|
||||
[root@localhost text]# du -sh sun.txt
|
||||
1.1M sun.txt
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost text<span class="token punctuation">]</span><span class="token comment"># dd if=/dev/zero of=sun.txt bs=1M count=1</span>
|
||||
<span class="token number">1</span>+0 records <span class="token keyword">in</span>
|
||||
<span class="token number">1</span>+0 records out
|
||||
<span class="token number">1048576</span> bytes <span class="token punctuation">(</span><span class="token number">1.0</span> MB<span class="token punctuation">)</span> copied, <span class="token number">0.006107</span> seconds, <span class="token number">172</span> MB/s
|
||||
|
|
@ -126,11 +145,17 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<p>以上命令可以看出dd命令来测试内存操作速度:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">1048576</span> bytes <span class="token punctuation">(</span><span class="token number">1.0</span> MB<span class="token punctuation">)</span> copied, <span class="token number">0.006107</span> seconds, <span class="token number">172</span> MB/s
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="1048576 bytes (1.0 MB) copied, 0.006107 seconds, 172 MB/s
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">1048576</span> bytes <span class="token punctuation">(</span><span class="token number">1.0</span> MB<span class="token punctuation">)</span> copied, <span class="token number">0.006107</span> seconds, <span class="token number">172</span> MB/s
|
||||
</code></pre>
|
||||
<p><strong>生成随机字符串</strong></p>
|
||||
<p>我们甚至可以使用 /dev/urandom 设备配合 dd 命令 来获取随机字符串。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dd if=/dev/urandom bs=1 count=15|base64 -w 0</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# dd if=/dev/urandom bs=1 count=15|base64 -w 0
|
||||
15+0 records in
|
||||
15+0 records out
|
||||
15 bytes (15 B) copied, 0.000111993 s, 134 kB/s
|
||||
wFRAnlkXeBXmWs1MyGEs
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dd if=/dev/urandom bs=1 count=15|base64 -w 0</span>
|
||||
<span class="token number">15</span>+0 records <span class="token keyword">in</span>
|
||||
<span class="token number">15</span>+0 records out
|
||||
<span class="token number">15</span> bytes <span class="token punctuation">(</span><span class="token number">15</span> B<span class="token punctuation">)</span> copied, <span class="token number">0.000111993</span> s, <span class="token number">134</span> kB/s
|
||||
|
|
@ -161,7 +186,7 @@ wFRAnlkXeBXmWs1MyGEs
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199677"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199677"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220882"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220882"></script>
|
||||
</body>
|
||||
</html>
|
||||
132
c/declare.html
132
c/declare.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,declare,声明变量,设置或显示变量的值和属性。">
|
||||
<title>declare 命令,Linux declare 命令详解:声明变量,设置或显示变量的值和属性。 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199733">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220927">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,7 +55,8 @@
|
|||
<h1 id="declare"><a class="anchor" aria-hidden="true" tabindex="-1" href="#declare"><span class="octicon octicon-link"></span></a>declare</h1>
|
||||
<p>声明变量,设置或显示变量的值和属性。</p>
|
||||
<h2 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token builtin class-name">declare</span> <span class="token punctuation">[</span>-aAfFgilnrtux<span class="token punctuation">]</span> <span class="token punctuation">[</span>-p<span class="token punctuation">]</span> <span class="token punctuation">[</span>name<span class="token punctuation">[</span><span class="token operator">=</span>value<span class="token punctuation">]</span> <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="declare [-aAfFgilnrtux] [-p] [name[=value] ...]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token builtin class-name">declare</span> <span class="token punctuation">[</span>-aAfFgilnrtux<span class="token punctuation">]</span> <span class="token punctuation">[</span>-p<span class="token punctuation">]</span> <span class="token punctuation">[</span>name<span class="token punctuation">[</span><span class="token operator">=</span>value<span class="token punctuation">]</span> <span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h2 id="主要用途"><a class="anchor" aria-hidden="true" tabindex="-1" href="#主要用途"><span class="octicon octicon-link"></span></a>主要用途</h2>
|
||||
<ul>
|
||||
|
|
@ -74,7 +75,28 @@
|
|||
<li>增加、删除变量的属性(可选:赋值)</li>
|
||||
</ul>
|
||||
<h2 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h2>
|
||||
<pre class="language-shell"><code class="language-shell">-f 将操作或显示限制为函数名及函数定义。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-f 将操作或显示限制为函数名及函数定义。
|
||||
-F 只显示函数名(调试时附加行号和源文件)。
|
||||
-g 在shell函数中使用时创建全局变量;其他情况下忽略。
|
||||
-p 显示每个名称的属性和值。
|
||||
|
||||
*设置属性的选项:
|
||||
-a 创建数组(如果支持)。
|
||||
-A 创建关联数组(如果支持)。
|
||||
-i 增加整型属性。
|
||||
+i 删除整型属性。
|
||||
-l 增加小写属性,变量的值将转换为小写。
|
||||
+l 删除小写属性。
|
||||
-n 增加引用属性(如果该选项存在)。
|
||||
+n 删除引用属性(如果该选项存在)。
|
||||
-r 增加只读属性。
|
||||
-t 增加追踪属性。
|
||||
+t 删除追踪属性。
|
||||
-u 增加大写属性,变量的值将转换为大写。
|
||||
+u 删除大写属性。
|
||||
-x 增加导出属性。
|
||||
+x 删除导出属性。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-f 将操作或显示限制为函数名及函数定义。
|
||||
-F 只显示函数名(调试时附加行号和源文件)。
|
||||
-g 在shell函数中使用时创建全局变量;其他情况下忽略。
|
||||
-p 显示每个名称的属性和值。
|
||||
|
|
@ -97,13 +119,33 @@
|
|||
+x 删除导出属性。
|
||||
</code></pre>
|
||||
<h2 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h2>
|
||||
<pre class="language-shell"><code class="language-shell">name(可选):变量名或函数名。
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="name(可选):变量名或函数名。
|
||||
value(可选):变量的值。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">name(可选):变量名或函数名。
|
||||
value(可选):变量的值。
|
||||
</code></pre>
|
||||
<h2 id="返回值"><a class="anchor" aria-hidden="true" tabindex="-1" href="#返回值"><span class="octicon octicon-link"></span></a>返回值</h2>
|
||||
<p>declare 返回true除非你提供了非法选项或赋值错误。具体导致异常的情况请查看<strong>讨论</strong>章节的<strong>关于异常情况</strong>。</p>
|
||||
<h2 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h2>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 声明变量,当然也欢迎您在这个网站(感谢本项目发起人 @jaywcjlove)查询linux命令。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 声明变量,当然也欢迎您在这个网站(感谢本项目发起人 @jaywcjlove)查询linux命令。
|
||||
declare reference_website='https://wangchujiang.com/linux-command/'
|
||||
|
||||
# 显示所有包含整型属性的变量和值。
|
||||
declare -i
|
||||
# 定义变量b并赋值为3,具有整型属性。
|
||||
declare -i b=5
|
||||
# 显示属性,返回 declare -i b="5"。
|
||||
declare -p b
|
||||
# 删除整型属性。
|
||||
declare +i b
|
||||
# 显示属性,返回 declare -- b="5"。
|
||||
declare -p b
|
||||
# 根据变量属性强制转换值的英文大小写。
|
||||
declare -u uc_var='abc'
|
||||
declare -l lc_var='ABC'
|
||||
# 显示'ABC abc';
|
||||
echo "${uc_var} ${lc_var}"
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 声明变量,当然也欢迎您在这个网站(感谢本项目发起人 @jaywcjlove)查询linux命令。</span>
|
||||
<span class="token builtin class-name">declare</span> <span class="token assign-left variable">reference_website</span><span class="token operator">=</span><span class="token string">'https://wangchujiang.com/linux-command/'</span>
|
||||
|
||||
<span class="token comment"># 显示所有包含整型属性的变量和值。</span>
|
||||
|
|
@ -122,7 +164,42 @@ value(可选):变量的值。
|
|||
<span class="token comment"># 显示'ABC abc';</span>
|
||||
<span class="token builtin class-name">echo</span> <span class="token string">"<span class="token variable">${uc_var}</span> <span class="token variable">${lc_var}</span>"</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 定义函数内的全局变量</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 定义函数内的全局变量
|
||||
function test(){
|
||||
declare -g a=3
|
||||
# 或者
|
||||
local -g b=3
|
||||
# 或者
|
||||
c=3
|
||||
# 让我们查看它们的属性。
|
||||
declare -p a b c
|
||||
}
|
||||
# 执行函数。
|
||||
test
|
||||
# 返回结果。
|
||||
# declare -- a="3"
|
||||
# declare -- b="3"
|
||||
# declare -- c="3"
|
||||
|
||||
# 定义函数外的全局变量
|
||||
declare a=3
|
||||
b=3
|
||||
declare –p a b
|
||||
# 返回结果如下。
|
||||
# declare -- a="3"
|
||||
# declare -- b="3"
|
||||
|
||||
# 定义局部变量
|
||||
function test2(){
|
||||
local -i a=3
|
||||
declare -i b=3
|
||||
}
|
||||
test2
|
||||
# 没有该变量(已经被销毁了)
|
||||
echo "${a} ${b}"
|
||||
# 因此,我们日常脚本中最常见的类似于'a=3'实际上是声明并赋值了一个全局变量。
|
||||
# 在接下来的 **讨论** 环节会延伸讨论全局和局部变量问题。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 定义函数内的全局变量</span>
|
||||
<span class="token keyword">function</span> <span class="token function-name function">test</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
|
||||
<span class="token builtin class-name">declare</span> -g <span class="token assign-left variable">a</span><span class="token operator">=</span><span class="token number">3</span>
|
||||
<span class="token comment"># 或者</span>
|
||||
|
|
@ -158,7 +235,21 @@ test2
|
|||
<span class="token comment"># 因此,我们日常脚本中最常见的类似于'a=3'实际上是声明并赋值了一个全局变量。</span>
|
||||
<span class="token comment"># 在接下来的 **讨论** 环节会延伸讨论全局和局部变量问题。</span>
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 注意,不能使用 `+a` 或 `+A` 取消数组,也不能使用 `+r` 取消只读属性。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 注意,不能使用 `+a` 或 `+A` 取消数组,也不能使用 `+r` 取消只读属性。
|
||||
|
||||
# 定义只读数组,设置属性的同时定义赋值。
|
||||
declare -ar season=('Spring' 'Summer' 'Autumn' 'Winter')
|
||||
# 或者这样。
|
||||
season=('Spring' 'Summer' 'Autumn' 'Winter')
|
||||
declare -ar season
|
||||
# 显示所有数组。
|
||||
declare -a
|
||||
# 定义关联数组。
|
||||
|
||||
declare -A fruits=(['apple']='red' ['banana']='yellow')
|
||||
# 显示所有关联数组。
|
||||
declare -A
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 注意,不能使用 `+a` 或 `+A` 取消数组,也不能使用 `+r` 取消只读属性。</span>
|
||||
|
||||
<span class="token comment"># 定义只读数组,设置属性的同时定义赋值。</span>
|
||||
<span class="token builtin class-name">declare</span> -ar <span class="token assign-left variable">season</span><span class="token operator">=</span><span class="token punctuation">(</span><span class="token string">'Spring'</span> <span class="token string">'Summer'</span> <span class="token string">'Autumn'</span> <span class="token string">'Winter'</span><span class="token punctuation">)</span>
|
||||
|
|
@ -173,14 +264,33 @@ test2
|
|||
<span class="token comment"># 显示所有关联数组。</span>
|
||||
<span class="token builtin class-name">declare</span> -A
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 显示所有变量的属性和值并显示函数的定义,输出很长。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 显示所有变量的属性和值并显示函数的定义,输出很长。
|
||||
declare
|
||||
# 显示所有变量的属性和值。
|
||||
declare -p
|
||||
# 显示所有全局变量的属性和值。
|
||||
declare -g
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 显示所有变量的属性和值并显示函数的定义,输出很长。</span>
|
||||
<span class="token builtin class-name">declare</span>
|
||||
<span class="token comment"># 显示所有变量的属性和值。</span>
|
||||
<span class="token builtin class-name">declare</span> -p
|
||||
<span class="token comment"># 显示所有全局变量的属性和值。</span>
|
||||
<span class="token builtin class-name">declare</span> -g
|
||||
</code></pre>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token comment"># 显示全部函数名和函数定义。</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="# 显示全部函数名和函数定义。
|
||||
declare -f
|
||||
# 只显示全部函数名。
|
||||
declare -F
|
||||
|
||||
# 定义两个函数。
|
||||
function func_a(){ echo $(date +"%F %T"); }
|
||||
function func_b(){ cd /; ls -lh --sort=time; }
|
||||
# 显示一到多个函数名和函数定义。
|
||||
declare -f func_a func_b
|
||||
# 只显示一到多个函数名,验证某个名称是否已经定义为函数时有用。
|
||||
declare -F func_a func_b
|
||||
# 最好不要让函数名和变量名相同。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token comment"># 显示全部函数名和函数定义。</span>
|
||||
<span class="token builtin class-name">declare</span> -f
|
||||
<span class="token comment"># 只显示全部函数名。</span>
|
||||
<span class="token builtin class-name">declare</span> -F
|
||||
|
|
@ -268,7 +378,7 @@ test2
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199734"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199734"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220928"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220928"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,depmod,分析可载入模块的相依性">
|
||||
<title>depmod 命令,Linux depmod 命令详解:分析可载入模块的相依性 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199757">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220942">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,20 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>depmod命令</strong> 可产生模块依赖的映射文件,在构建嵌入式系统时,需要由这个命令来生成相应的文件,由modprobe使用。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">depmod<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="depmod(选项)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">depmod<span class="token punctuation">(</span>选项<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a或--all:分析所有可用的模块;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a或--all:分析所有可用的模块;
|
||||
-d或debug:执行排错模式;
|
||||
-e:输出无法参照的符号;
|
||||
-i:不检查符号表的版本;
|
||||
-m<文件>或system-map<文件>:使用指定的符号表文件;
|
||||
-s或--system-log:在系统记录中记录错误;
|
||||
-v或--verbose:执行时显示详细的信息;
|
||||
-V或--version:显示版本信息;
|
||||
--help:显示帮助。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a或--all:分析所有可用的模块;
|
||||
-d或debug:执行排错模式;
|
||||
-e:输出无法参照的符号;
|
||||
-i:不检查符号表的版本;
|
||||
|
|
@ -71,7 +81,8 @@
|
|||
--help:显示帮助。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">depmod -b /home/windsome/EMMA3PF-KernelSource-20080626/install_pos -e -F ./boot/System.map -v <span class="token number">2.6</span>.18_pro500-bcm91250-mips2_fp_be -A -a
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="depmod -b /home/windsome/EMMA3PF-KernelSource-20080626/install_pos -e -F ./boot/System.map -v 2.6.18_pro500-bcm91250-mips2_fp_be -A -a
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">depmod -b /home/windsome/EMMA3PF-KernelSource-20080626/install_pos -e -F ./boot/System.map -v <span class="token number">2.6</span>.18_pro500-bcm91250-mips2_fp_be -A -a
|
||||
</code></pre>
|
||||
<ul>
|
||||
<li><code>/home/windsome/EMMA3PF-KernelSource-20080626/install_pos</code>是我<code>make mod_install</code>后,所有模块的存放路径。</li>
|
||||
|
|
@ -79,7 +90,19 @@
|
|||
<li><code>2.6.18_pro500-bcm91250-mips2_fp_be</code>是我build的linux的版本。</li>
|
||||
</ul>
|
||||
<p>编译linux过程及执行depmod的例子:</p>
|
||||
<pre class="language-shell"><code class="language-shell">genkernel.sh <span class="token punctuation">(</span>at linux-2.6.18_pro500<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="genkernel.sh (at linux-2.6.18_pro500)
|
||||
#######
|
||||
export INSTALL_ROOT_EMMA3PF="/home/windsome/EMMA3PF-KernelSource-20080626/install_pos"
|
||||
export INSTALL_MOD_EMMA3PF="/home/windsome/EMMA3PF-KernelSource-20080626/install_pos"
|
||||
rm /home/windsome/EMMA3PF-KernelSource-20080626/install_pos/lib -rf
|
||||
rm /home/windsome/EMMA3PF-KernelSource-20080626/install_pos/boot/* -rf
|
||||
cd <linux_src_dir>
|
||||
make
|
||||
make modules_install
|
||||
cp vmlinux System.map /home/windsome/EMMA3PF-KernelSource-20080626/install_pos/boot/ -p
|
||||
cd /home/windsome/EMMA3PF-KernelSource-20080626/install_pos
|
||||
depmod -b /home/windsome/EMMA3PF-KernelSource-20080626/install_pos -e -F ./boot/System.map -v 2.6.18_pro500-bcm91250-mips2_fp_be -A -a
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">genkernel.sh <span class="token punctuation">(</span>at linux-2.6.18_pro500<span class="token punctuation">)</span>
|
||||
<span class="token comment">#######</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">INSTALL_ROOT_EMMA3PF</span><span class="token operator">=</span><span class="token string">"/home/windsome/EMMA3PF-KernelSource-20080626/install_pos"</span>
|
||||
<span class="token builtin class-name">export</span> <span class="token assign-left variable">INSTALL_MOD_EMMA3PF</span><span class="token operator">=</span><span class="token string">"/home/windsome/EMMA3PF-KernelSource-20080626/install_pos"</span>
|
||||
|
|
@ -120,7 +143,7 @@ depmod -b /home/windsome/EMMA3PF-KernelSource-20080626/install_pos -e -F ./boot/
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199757"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199757"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220943"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220943"></script>
|
||||
</body>
|
||||
</html>
|
||||
60
c/df.html
60
c/df.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,df,显示磁盘的相关信息">
|
||||
<title>df 命令,Linux df 命令详解:显示磁盘的相关信息 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199775">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220957">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,27 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>df命令</strong> 用于显示磁盘分区上的可使用的磁盘空间。默认显示单位为KB。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">df<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="df(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">df<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a或--all:包含全部的文件系统;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a或--all:包含全部的文件系统;
|
||||
--block-size=<区块大小>:以指定的区块大小来显示区块数目;
|
||||
-h或--human-readable:以可读性较高的方式来显示信息;
|
||||
-H或--si:与-h参数相同,但在计算时是以1000 Bytes为换算单位而非1024 Bytes;
|
||||
-i或--inodes:显示inode的信息;
|
||||
-k或--kilobytes:指定区块大小为1024字节;
|
||||
-l或--local:仅显示本地端的文件系统;
|
||||
-m或--megabytes:指定区块大小为1048576字节;
|
||||
--no-sync:在取得磁盘使用信息前,不要执行sync指令,此为预设值;
|
||||
-P或--portability:使用POSIX的输出格式;
|
||||
--sync:在取得磁盘使用信息前,先执行sync指令;
|
||||
-t<文件系统类型>或--type=<文件系统类型>:仅显示指定文件系统类型的磁盘信息;
|
||||
-T或--print-type:显示文件系统的类型;
|
||||
-x<文件系统类型>或--exclude-type=<文件系统类型>:不要显示指定文件系统类型的磁盘信息;
|
||||
--help:显示帮助;
|
||||
--version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a或--all:包含全部的文件系统;
|
||||
--block-size<span class="token operator">=</span><span class="token operator"><</span>区块大小<span class="token operator">></span>:以指定的区块大小来显示区块数目;
|
||||
-h或--human-readable:以可读性较高的方式来显示信息;
|
||||
-H或--si:与-h参数相同,但在计算时是以1000 Bytes为换算单位而非1024 Bytes;
|
||||
|
|
@ -84,7 +101,13 @@
|
|||
<p>SIZE是一个整数和可选单位(例如:10M是10 * 1024 * 1024)。 单位是K,M,G,T,P,E,Z,Y(1024的幂)或KB,MB,...(1000的幂)。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>查看系统磁盘设备,默认是KB为单位:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@LinServ-1 ~]# df
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 146294492 28244432 110498708 21% /
|
||||
/dev/sda1 1019208 62360 904240 7% /boot
|
||||
tmpfs 1032204 0 1032204 0% /dev/shm
|
||||
/dev/sdb1 2884284108 218826068 2518944764 8% /data1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df</span>
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 <span class="token number">146294492</span> <span class="token number">28244432</span> <span class="token number">110498708</span> <span class="token number">21</span>% /
|
||||
/dev/sda1 <span class="token number">1019208</span> <span class="token number">62360</span> <span class="token number">904240</span> <span class="token number">7</span>% /boot
|
||||
|
|
@ -92,7 +115,13 @@ tmpfs <span class="token number">1032204</span> <span c
|
|||
/dev/sdb1 <span class="token number">2884284108</span> <span class="token number">218826068</span> <span class="token number">2518944764</span> <span class="token number">8</span>% /data1
|
||||
</code></pre>
|
||||
<p>使用<code>-h</code>选项以KB以上的单位来显示,可读性高:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -h</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@LinServ-1 ~]# df -h
|
||||
文件系统 容量 已用 可用 已用% 挂载点
|
||||
/dev/sda2 140G 27G 106G 21% /
|
||||
/dev/sda1 996M 61M 884M 7% /boot
|
||||
tmpfs 1009M 0 1009M 0% /dev/shm
|
||||
/dev/sdb1 2.7T 209G 2.4T 8% /data1
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -h</span>
|
||||
文件系统 容量 已用 可用 已用% 挂载点
|
||||
/dev/sda2 140G 27G 106G <span class="token number">21</span>% /
|
||||
/dev/sda1 996M 61M 884M <span class="token number">7</span>% /boot
|
||||
|
|
@ -100,7 +129,17 @@ tmpfs 1009M <span class="token number">0</span> 1009M <span
|
|||
/dev/sdb1 <span class="token number">2</span>.7T 209G <span class="token number">2</span>.4T <span class="token number">8</span>% /data1
|
||||
</code></pre>
|
||||
<p>查看全部文件系统:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -a</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@LinServ-1 ~]# df -a
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 146294492 28244432 110498708 21% /
|
||||
proc 0 0 0 - /proc
|
||||
sysfs 0 0 0 - /sys
|
||||
devpts 0 0 0 - /dev/pts
|
||||
/dev/sda1 1019208 62360 904240 7% /boot
|
||||
tmpfs 1032204 0 1032204 0% /dev/shm
|
||||
/dev/sdb1 2884284108 218826068 2518944764 8% /data1
|
||||
none 0 0 0 - /proc/sys/fs/binfmt_misc
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@LinServ-1 ~<span class="token punctuation">]</span><span class="token comment"># df -a</span>
|
||||
文件系统 1K-块 已用 可用 已用% 挂载点
|
||||
/dev/sda2 <span class="token number">146294492</span> <span class="token number">28244432</span> <span class="token number">110498708</span> <span class="token number">21</span>% /
|
||||
proc <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /proc
|
||||
|
|
@ -112,7 +151,10 @@ tmpfs <span class="token number">1032204</span> <span c
|
|||
none <span class="token number">0</span> <span class="token number">0</span> <span class="token number">0</span> - /proc/sys/fs/binfmt_misc
|
||||
</code></pre>
|
||||
<p>显示 <code>public</code> 目录中的可用空间量,如以下输出中所示:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">df</span> public
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="df public
|
||||
# Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
# /dev/loop0 18761008 15246924 2554392 86% /d Avail
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">df</span> public
|
||||
<span class="token comment"># Filesystem 1K-blocks Used Available Use% Mounted on</span>
|
||||
<span class="token comment"># /dev/loop0 18761008 15246924 2554392 86% /d Avail</span>
|
||||
</code></pre>
|
||||
|
|
@ -141,7 +183,7 @@ none <span class="token number">0</span> <span c
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199776"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199776"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220958"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220958"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dhclient,动态获取或释放IP地址">
|
||||
<title>dhclient 命令,Linux dhclient 命令详解:动态获取或释放IP地址 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199782">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220964">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>dhclient命令</strong> 使用动态主机配置协议动态的配置网络接口的网络参数。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dhclient<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dhclient(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dhclient<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token number">0</span>:指定dhcp客户端监听的端口号;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="0:指定dhcp客户端监听的端口号;
|
||||
-d:总是以前台方式运行程序;
|
||||
-q:安静模式,不打印任何错误的提示信息;
|
||||
-r:释放ip地址。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token number">0</span>:指定dhcp客户端监听的端口号;
|
||||
-d:总是以前台方式运行程序;
|
||||
-q:安静模式,不打印任何错误的提示信息;
|
||||
-r:释放ip地址。
|
||||
|
|
@ -68,7 +73,9 @@
|
|||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>网络接口:操作的网络接口。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dhclient -r <span class="token comment">#释放IP</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dhclient -r #释放IP
|
||||
dhclient #获取IP
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dhclient -r <span class="token comment">#释放IP</span>
|
||||
dhclient <span class="token comment">#获取IP</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -96,7 +103,7 @@ dhclient <span class="token comment">#获取IP</span>
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199783"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199783"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220964"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220964"></script>
|
||||
</body>
|
||||
</html>
|
||||
46
c/dhcpd.html
46
c/dhcpd.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dhcpd,运行DHCP服务器">
|
||||
<title>dhcpd 命令,Linux dhcpd 命令详解:运行DHCP服务器 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199792">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220972">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -55,10 +55,24 @@
|
|||
<h1 id="dhcpd"><a class="anchor" aria-hidden="true" tabindex="-1" href="#dhcpd"><span class="octicon octicon-link"></span></a>dhcpd</h1>
|
||||
<p>运行DHCP服务器</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dhcpd <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> <span class="token punctuation">[</span>网络接口<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dhcpd [选项] [网络接口]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dhcpd <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> <span class="token punctuation">[</span>网络接口<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-p <span class="token operator"><</span>端口<span class="token operator">></span> 指定dhcpd监听的端口
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-p <端口> 指定dhcpd监听的端口
|
||||
-f 作为前台进程运行dhcpd
|
||||
-d 启用调试模式
|
||||
-q 在启动时不显示版权信息
|
||||
-t 简单地测试配置文件的语法是否正确的,但不会尝试执行任何网络操作
|
||||
-T 可以用来测试租约数据库文件
|
||||
-4 运行DHCP服务器
|
||||
-6 运行DHCPv6服务器
|
||||
-s <服务器> 指定发送回复的服务器
|
||||
-cf <配置文件> 指定配置文件
|
||||
-lf <租约文件> 指定租约文件
|
||||
-pf <PID文件> 指定PID文件
|
||||
-tf <跟踪输出文件> 指定文件记录DHCP服务器的整个启动状态
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-p <span class="token operator"><</span>端口<span class="token operator">></span> 指定dhcpd监听的端口
|
||||
-f 作为前台进程运行dhcpd
|
||||
-d 启用调试模式
|
||||
-q 在启动时不显示版权信息
|
||||
|
|
@ -74,7 +88,27 @@
|
|||
</code></pre>
|
||||
<h3 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h3>
|
||||
<p>对DHCP服务器进行排错。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dhcpd</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# dhcpd
|
||||
InternetSystems Consortium DHCP Server 4.1.1-P1
|
||||
Copyright2004-2010 Internet Systems Consortium.
|
||||
All rightsreserved.
|
||||
For info,please visit https://www.isc.org/software/dhcp/
|
||||
Not searchingLDAP since ldap-server, ldap-port and ldap-base-dn were not specified in theconfig file
|
||||
Wrote 0deleted host decls to leases file.
|
||||
Wrote 0 newdynamic host decls to leases file.
|
||||
Wrote 1leases to leases file.
|
||||
Listening onLPF/eth0/00:0c:29:fc:2f:e5/192.168.0.0/24
|
||||
Sendingon LPF/eth0/00:0c:29:fc:2f:e5/192.168.0.0/24
|
||||
Sendingon Socket/fallback/fallback-net
|
||||
[root@rhel~]# There's already a DHCP server running.
|
||||
|
||||
This versionof ISC DHCP is based on the release available
|
||||
onftp.isc.org. Features have been addedand other changes
|
||||
have beenmade to the base software release in order to make
|
||||
it workbetter with this distribution.
|
||||
|
||||
exiting.
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dhcpd</span>
|
||||
InternetSystems Consortium DHCP Server <span class="token number">4.1</span>.1-P1
|
||||
Copyright2004-2010 Internet Systems Consortium.
|
||||
All rightsreserved.
|
||||
|
|
@ -120,7 +154,7 @@ exiting.
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199793"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199793"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220973"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220973"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dhcrelay,使用dhcrelay命令可以提供中继DHCP和BOOTP请求">
|
||||
<title>dhcrelay 命令,Linux dhcrelay 命令详解:使用dhcrelay命令可以提供中继DHCP和BOOTP请求 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199802">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220980">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,18 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>dhcrelay命令</strong> 使用dhcrelay命令可以提供中继DHCP和BOOTP请求,从一个没有DHCP服务器的子网直接连接到其它子网内的一个或多个DHCP服务器。该命令在DHCP中继服务器上使用,同时支持DHCPv4/BOOTP和DHCPv6协议。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dhcrelay <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> <span class="token punctuation">[</span>DHCP服务器<span class="token punctuation">]</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dhcrelay [选项] [DHCP服务器]
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dhcrelay <span class="token punctuation">[</span>选项<span class="token punctuation">]</span> <span class="token punctuation">[</span>DHCP服务器<span class="token punctuation">]</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-c <span class="token operator"><</span>跳数<span class="token operator">></span> 当转发数据包时,dhcrelay丢弃已经达到一个最大跳数的数据包。默认值是10,最大值是255
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-c <跳数> 当转发数据包时,dhcrelay丢弃已经达到一个最大跳数的数据包。默认值是10,最大值是255
|
||||
-4 运行dhcrelay命令作为DHCPv4/BOOTP中继代理。这是默认操作模式
|
||||
-6 运行dhcrelay命令作为DHCPv6中继代理
|
||||
-q 安静模式
|
||||
-p <端口> 监听和发送端口。DHCPv4/BOOTP默认端口是67,DHCPv6默认端口是547
|
||||
-A <长度> 指定发送到DHCP服务器的最大数据包大小
|
||||
-d 强制dhcrelay命令作为前台进程运行
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-c <span class="token operator"><</span>跳数<span class="token operator">></span> 当转发数据包时,dhcrelay丢弃已经达到一个最大跳数的数据包。默认值是10,最大值是255
|
||||
-4 运行dhcrelay命令作为DHCPv4/BOOTP中继代理。这是默认操作模式
|
||||
-6 运行dhcrelay命令作为DHCPv6中继代理
|
||||
-q 安静模式
|
||||
|
|
@ -70,7 +78,17 @@
|
|||
</code></pre>
|
||||
<h3 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h3>
|
||||
<p>指定DHCP服务器的位置。</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dhcrelay 192.168.0.2</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# dhcrelay 192.168.0.2
|
||||
Internet Systems Consortium DHCP Relay Agent4.1.1-P1
|
||||
Copyright 2004-2010 Internet SystemsConsortium.
|
||||
All rights reserved.
|
||||
For info, please visithttps://www.isc.org/software/dhcp/
|
||||
Listening on LPF/eth1/00:0c:29:fc:2f:ef
|
||||
Sending on LPF/eth1/00:0c:29:fc:2f:ef
|
||||
Listening on LPF/eth0/00:0c:27:fc:25:ec
|
||||
Sending on LPF/eth0/00:0c:27:fc:25:ec
|
||||
Sending on Socket/fallback
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dhcrelay 192.168.0.2</span>
|
||||
Internet Systems Consortium DHCP Relay Agent4.1.1-P1
|
||||
Copyright <span class="token number">2004</span>-2010 Internet SystemsConsortium.
|
||||
All rights reserved.
|
||||
|
|
@ -106,7 +124,7 @@ Sending on Socket/fallback
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199802"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199802"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220980"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220980"></script>
|
||||
</body>
|
||||
</html>
|
||||
53
c/diff.html
53
c/diff.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,diff,比较给定的两个文件的不同">
|
||||
<title>diff 命令,Linux diff 命令详解:比较给定的两个文件的不同 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199817">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220991">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,45 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>diff命令</strong> 在最简单的情况下,比较给定的两个文件的不同。如果使用“-”代替“文件”参数,则要比较的内容将来自标准输入。diff命令是以逐行的方式,比较文本文件的异同处。如果该命令指定进行目录的比较,则将会比较该目录中具有相同文件名的文件,而不会对其子目录文件进行任何比较操作。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">diff<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="diff(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">diff<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-<span class="token operator"><</span>行数<span class="token operator">></span>:指定要显示多少行的文本。此参数必须与-c或-u参数一并使用;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-<行数>:指定要显示多少行的文本。此参数必须与-c或-u参数一并使用;
|
||||
-a或——text:diff预设只会逐行比较文本文件;
|
||||
-b或--ignore-space-change:不检查空格字符的不同;
|
||||
-B或--ignore-blank-lines:不检查空白行;
|
||||
-c:显示全部内容,并标出不同之处;
|
||||
-C<行数>或--context<行数>:与执行“-c-<行数>”指令相同;
|
||||
-d或——minimal:使用不同的演算法,以小的单位来做比较;
|
||||
-D<巨集名称>或ifdef<巨集名称>:此参数的输出格式可用于前置处理器巨集;
|
||||
-e或——ed:此参数的输出格式可用于ed的script文件;
|
||||
-f或-forward-ed:输出的格式类似ed的script文件,但按照原来文件的顺序来显示不同处;
|
||||
-H或--speed-large-files:比较大文件时,可加快速度;
|
||||
-l<字符或字符串>或--ignore-matching-lines<字符或字符串>:若两个文件在某几行有所不同,而之际航同时都包含了选项中指定的字符或字符串,则不显示这两个文件的差异;
|
||||
-i或--ignore-case:不检查大小写的不同;
|
||||
-l或——paginate:将结果交由pr程序来分页;
|
||||
-n或——rcs:将比较结果以RCS的格式来显示;
|
||||
-N或--new-file:在比较目录时,若文件A仅出现在某个目录中,预设会显示:Only in目录,文件A 若使用-N参数,则diff会将文件A 与一个空白的文件比较;
|
||||
-p:若比较的文件为C语言的程序码文件时,显示差异所在的函数名称;
|
||||
-P或--unidirectional-new-file:与-N类似,但只有当第二个目录包含了第一个目录所没有的文件时,才会将这个文件与空白的文件做比较;
|
||||
-q或--brief:仅显示有无差异,不显示详细的信息;
|
||||
-r或——recursive:比较子目录中的文件;
|
||||
-s或--report-identical-files:若没有发现任何差异,仍然显示信息;
|
||||
-S<文件>或--starting-file<文件>:在比较目录时,从指定的文件开始比较;
|
||||
-t或--expand-tabs:在输出时,将tab字符展开;
|
||||
-T或--initial-tab:在每行前面加上tab字符以便对齐;
|
||||
-u,-U<列数>或--unified=<列数>:以合并的方式来显示文件内容的不同;
|
||||
-v或——version:显示版本信息;
|
||||
-w或--ignore-all-space:忽略全部的空格字符;
|
||||
-W<宽度>或--width<宽度>:在使用-y参数时,指定栏宽;
|
||||
-x<文件名或目录>或--exclude<文件名或目录>:不比较选项中所指定的文件或目录;
|
||||
-X<文件>或--exclude-from<文件>;您可以将文件或目录类型存成文本文件,然后在=<文件>中指定此文本文件;
|
||||
-y或--side-by-side:以并列的方式显示文件的异同之处;
|
||||
--help:显示帮助;
|
||||
--left-column:在使用-y参数时,若两个文件某一行内容相同,则仅在左侧的栏位显示该行内容;
|
||||
--suppress-common-lines:在使用-y参数时,仅显示不同之处。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-<span class="token operator"><</span>行数<span class="token operator">></span>:指定要显示多少行的文本。此参数必须与-c或-u参数一并使用;
|
||||
-a或——text:diff预设只会逐行比较文本文件;
|
||||
-b或--ignore-space-change:不检查空格字符的不同;
|
||||
-B或--ignore-blank-lines:不检查空白行;
|
||||
|
|
@ -102,10 +137,14 @@
|
|||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将目录<code>/usr/li</code>下的文件"test.txt"与当前目录下的文件"test.txt"进行比较,输入如下命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">diff</span> /usr/li test.txt <span class="token comment">#使用diff指令对文件进行比较</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="diff /usr/li test.txt #使用diff指令对文件进行比较
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">diff</span> /usr/li test.txt <span class="token comment">#使用diff指令对文件进行比较</span>
|
||||
</code></pre>
|
||||
<p>上面的命令执行后,会将比较后的不同之处以指定的形式列出,如下所示:</p>
|
||||
<pre class="language-shell"><code class="language-shell">n1 a n3,n4
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="n1 a n3,n4
|
||||
n1,n2 d n3
|
||||
n1,n2 c n3,n4
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">n1 a n3,n4
|
||||
n1,n2 d n3
|
||||
n1,n2 c n3,n4
|
||||
</code></pre>
|
||||
|
|
@ -136,7 +175,7 @@ n1,n2 c n3,n4
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199817"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199817"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220991"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220991"></script>
|
||||
</body>
|
||||
</html>
|
||||
18
c/diff3.html
18
c/diff3.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,diff3,比较3个文件不同的地方">
|
||||
<title>diff3 命令,Linux diff3 命令详解:比较3个文件不同的地方 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199826">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357220998">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,18 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>diff3命令</strong> 用于比较3个文件,将3个文件的不同的地方显示到标准输出。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">diff3<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="diff3(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">diff3<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-a:把所有的文件都当做文本文件按照行为单位进行比较,即给定的文件不是文本文件;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-a:把所有的文件都当做文本文件按照行为单位进行比较,即给定的文件不是文本文件;
|
||||
-A:合并第2个文件和第3个文件之间的不同到第1个文件中,有冲突内容用括号括起来;
|
||||
-B:与选项“-A”功能相同,但是不显示冲突的内容;
|
||||
-e/--ed:生成一个“-ed”脚本,用于将第2个文件和第3个文件之间的不同合并到第1个文件中;
|
||||
--easy-only:除了不显示互相重叠的变化,与选项“-e”的功能相同;
|
||||
-i:为了和system V系统兼容,在“ed”脚本的最后生成“w”和“q”命令。此选项必须和选项“-AeExX3”连用,但是不能和“-m”连用;
|
||||
--initial-tab:在正常格式的行的文本前,输出一个TAB字符而非两个空白字符。此选项将导致在行中TAB字符的对齐方式看上去规范。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-a:把所有的文件都当做文本文件按照行为单位进行比较,即给定的文件不是文本文件;
|
||||
-A:合并第2个文件和第3个文件之间的不同到第1个文件中,有冲突内容用括号括起来;
|
||||
-B:与选项“-A”功能相同,但是不显示冲突的内容;
|
||||
-e/--ed:生成一个“-ed”脚本,用于将第2个文件和第3个文件之间的不同合并到第1个文件中;
|
||||
|
|
@ -99,7 +107,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199827"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199827"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357220998"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357220998"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,diffstat,显示diff命令输出信息的柱状图">
|
||||
<title>diffstat 命令,Linux diffstat 命令详解:显示diff命令输出信息的柱状图 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199837">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357221009">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,15 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>diffstat命令</strong> 用来显示diff命令输出信息的柱状图,用以显示diff命令比较两个文件的不同统计信息。用户也可以直接使用<code>|</code>将diff命令所输出的结果直接送给diffstat命令进行统计结果的显示。使用该命令时,若所比较的文件或者子目录不在当前目录下,则应该使用其完整路径。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">diffstat<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="diffstat(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">diffstat<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-n<span class="token operator"><</span>文件名长度<span class="token operator">></span>:指定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-n<文件名长度>:指定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名;
|
||||
-p<文件名长度>:与-n参数相同,但此处的<文件名长度>包括了文件的路径;
|
||||
-w:指定要输出时栏位的宽度;
|
||||
-v:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-n<span class="token operator"><</span>文件名长度<span class="token operator">></span>:指定文件名长度,指定的长度必须大于或等于所有文件中最长的文件名;
|
||||
-p<span class="token operator"><</span>文件名长度<span class="token operator">></span>:与-n参数相同,但此处的<span class="token operator"><</span>文件名长度<span class="token operator">></span>包括了文件的路径;
|
||||
-w:指定要输出时栏位的宽度;
|
||||
-v:显示版本信息。
|
||||
|
|
@ -69,11 +74,28 @@
|
|||
<p>文件:指定保存有diff命令的输出信息文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<p>将目录"test1"和"test2"下的同名文件"testf.txt"使用diff命令进行比较。然后使用diffstat命令对结果进行统计显示,输入如下命令:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">diff</span> test1 test2 <span class="token operator">|</span> diffstat <span class="token comment">#进行比较结果的统计显示</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="diff test1 test2 | diffstat #进行比较结果的统计显示
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">diff</span> test1 test2 <span class="token operator">|</span> diffstat <span class="token comment">#进行比较结果的统计显示</span>
|
||||
</code></pre>
|
||||
<p>注意:使用这条命令可以非常方便地实现统计显示的功能。</p>
|
||||
<p>对于查看文件中的内容,用户可以通过cat命令进行查看即可,具体操作如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">cat</span> test1/testf.txt <span class="token comment">#查看test1/testf的内容</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="cat test1/testf.txt #查看test1/testf的内容
|
||||
abc
|
||||
def
|
||||
ghi
|
||||
jkl
|
||||
mno
|
||||
pqr
|
||||
stu
|
||||
vws
|
||||
|
||||
cat test2/testf.txt #查看test2/testf的内容
|
||||
abc
|
||||
def
|
||||
ghi
|
||||
jkl
|
||||
mno
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">cat</span> test1/testf.txt <span class="token comment">#查看test1/testf的内容</span>
|
||||
abc
|
||||
def
|
||||
ghi
|
||||
|
|
@ -91,7 +113,9 @@ jkl
|
|||
mno
|
||||
</code></pre>
|
||||
<p>从上面的文件内容显示,可以看到两个文件内容的差别。现在来运行刚才的命令,对文件比较的结果进行统计显示,结果如下:</p>
|
||||
<pre class="language-shell"><code class="language-shell">testfile <span class="token operator">|</span> <span class="token number">2</span> +- <span class="token comment">#统计信息输出显示</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="testfile | 2 +- #统计信息输出显示
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">testfile <span class="token operator">|</span> <span class="token number">2</span> +- <span class="token comment">#统计信息输出显示</span>
|
||||
<span class="token number">1</span> <span class="token function">file</span> changed, <span class="token number">1</span> insertion<span class="token punctuation">(</span>+<span class="token punctuation">)</span>, <span class="token number">1</span> deletion<span class="token punctuation">(</span>-<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
@ -119,7 +143,7 @@ mno
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199838"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199838"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357221010"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357221010"></script>
|
||||
</body>
|
||||
</html>
|
||||
45
c/dig.html
45
c/dig.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dig,域名查询工具">
|
||||
<title>dig 命令,Linux dig 命令详解:域名查询工具 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199851">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357221020">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,20 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>dig命令</strong> 是常用的域名查询工具,可以用来测试域名系统工作是否正常。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dig<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dig(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dig<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">@<span class="token operator"><</span>服务器地址<span class="token operator">></span>:指定进行域名解析的域名服务器;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="@<服务器地址>:指定进行域名解析的域名服务器;
|
||||
-b<ip地址>:当主机具有多个IP地址,指定使用本机的哪个IP地址向域名服务器发送域名查询请求;
|
||||
-f<文件名称>:指定dig以批处理的方式运行,指定的文件中保存着需要批处理查询的DNS任务信息;
|
||||
-P:指定域名服务器所使用端口号;
|
||||
-t<类型>:指定要查询的DNS数据类型;
|
||||
-x<IP地址>:执行逆向域名查询;
|
||||
-4:使用IPv4;
|
||||
-6:使用IPv6;
|
||||
-h:显示指令帮助信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">@<span class="token operator"><</span>服务器地址<span class="token operator">></span>:指定进行域名解析的域名服务器;
|
||||
-b<span class="token operator"><</span>ip地址<span class="token operator">></span>:当主机具有多个IP地址,指定使用本机的哪个IP地址向域名服务器发送域名查询请求;
|
||||
-f<span class="token operator"><</span>文件名称<span class="token operator">></span>:指定dig以批处理的方式运行,指定的文件中保存着需要批处理查询的DNS任务信息;
|
||||
-P:指定域名服务器所使用端口号;
|
||||
|
|
@ -78,7 +88,30 @@
|
|||
<li>查询选项:指定查询选项。</li>
|
||||
</ul>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dig www.jsdig.com</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# dig www.jsdig.com
|
||||
|
||||
; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.1 <<>> www.jsdig.com
|
||||
;; global options: printcmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2115
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 0
|
||||
|
||||
;; QUESTION SECTION:
|
||||
;www.jsdig.com. IN A
|
||||
|
||||
;; ANSWER SECTION:
|
||||
www.jsdig.com. 0 IN CNAME host.1.jsdig.com.
|
||||
host.1.jsdig.com. 0 IN A 100.42.212.8
|
||||
|
||||
;; AUTHORITY SECTION:
|
||||
jsdig.com. 8 IN NS f1g1ns2.dnspod.net.
|
||||
jsdig.com. 8 IN NS f1g1ns1.dnspod.net.
|
||||
|
||||
;; Query time: 0 msec
|
||||
;; SERVER: 202.96.104.15#53(202.96.104.15)
|
||||
;; WHEN: Thu Dec 26 11:14:37 2013
|
||||
;; MSG SIZE rcvd: 121
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dig www.jsdig.com</span>
|
||||
|
||||
<span class="token punctuation">;</span> <span class="token operator"><<</span><span class="token operator">>></span> DiG <span class="token number">9.3</span>.6-P1-RedHat-9.3.6-20.P1.el5_8.1 <span class="token operator"><<</span><span class="token operator">>></span> www.jsdig.com
|
||||
<span class="token punctuation">;</span><span class="token punctuation">;</span> global options: printcmd
|
||||
|
|
@ -127,7 +160,7 @@ jsdig.com. <span class="token number">8</span> IN NS
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199852"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199852"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357221020"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357221020"></script>
|
||||
</body>
|
||||
</html>
|
||||
127
c/dircolors.html
127
c/dircolors.html
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dircolors,置ls命令在显示目录或文件时所用的色彩">
|
||||
<title>dircolors 命令,Linux dircolors 命令详解:置ls命令在显示目录或文件时所用的色彩 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199873">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357221039">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,10 +57,16 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>dircolors命令</strong> 设置ls命令在显示目录或文件时所用的色彩。dircolors可根据[色彩配置文件]来设置LS_COLORS环境变量或是显示设置LS_COLORS环境变量的命令。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dircolors<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dircolors(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dircolors<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">-b或--sh或--bourne-shell:显示在Boume shell中,将<span class="token environment constant">LS_COLORS</span>设为目前预设置的shell指令;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="-b或--sh或--bourne-shell:显示在Boume shell中,将LS_COLORS设为目前预设置的shell指令;
|
||||
-c或--csh或--c-shell:显示在C shell中,将LS_COLORS设为目前预设置的shell指令;
|
||||
-p或--print-database:显示预设置;
|
||||
-help:显示帮助;
|
||||
-version:显示版本信息。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">-b或--sh或--bourne-shell:显示在Boume shell中,将<span class="token environment constant">LS_COLORS</span>设为目前预设置的shell指令;
|
||||
-c或--csh或--c-shell:显示在C shell中,将<span class="token environment constant">LS_COLORS</span>设为目前预设置的shell指令;
|
||||
-p或--print-database:显示预设置;
|
||||
-help:显示帮助;
|
||||
|
|
@ -69,7 +75,116 @@
|
|||
<h3 id="参数"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参数"><span class="octicon octicon-link"></span></a>参数</h3>
|
||||
<p>文件:指定用来设置颜色的文件。</p>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dircolors -p</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="[root@localhost ~]# dircolors -p
|
||||
# Configuration file for dircolors, a utility to help you set the
|
||||
# LS_COLORS environment variable used by GNU ls with the --color option.
|
||||
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
|
||||
# slackware version of dircolors) are recognized but ignored.
|
||||
# Below, there should be one TERM entry for each termtype that is colorizable
|
||||
TERM linux
|
||||
TERM linux-c
|
||||
TERM mach-color
|
||||
TERM console
|
||||
TERM con132x25
|
||||
TERM con132x30
|
||||
TERM con132x43
|
||||
TERM con132x60
|
||||
TERM con80x25
|
||||
TERM con80x28
|
||||
TERM con80x30
|
||||
TERM con80x43
|
||||
TERM con80x50
|
||||
TERM con80x60
|
||||
TERM cygwin
|
||||
TERM dtterm
|
||||
TERM putty
|
||||
TERM xterm
|
||||
TERM xterm-color
|
||||
TERM xterm-debian
|
||||
TERM rxvt
|
||||
TERM screen
|
||||
TERM screen-bce
|
||||
TERM screen-w
|
||||
TERM vt100
|
||||
TERM Eterm
|
||||
# Below are the color init strings for the basic file types. A color init
|
||||
# string consists of one or more of the following numeric codes:
|
||||
# Attribute codes:
|
||||
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
||||
# Text color codes:
|
||||
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
||||
# Background color codes:
|
||||
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
||||
NORMAL 00 # global default, although everything should be something.
|
||||
FILE 00 # normal file
|
||||
DIR 01;34 # directory
|
||||
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
|
||||
# numerical value, the color is as for the file pointed to.)
|
||||
FIFO 40;33 # pipe
|
||||
SOCK 01;35 # socket
|
||||
DOOR 01;35 # door
|
||||
BLK 40;33;01 # block device driver
|
||||
CHR 40;33;01 # character device driver
|
||||
ORPHAN 40;31;01 # symlink to nonexistent file
|
||||
SETUID 37;41 # file that is setuid (u+s)
|
||||
SETGID 30;43 # file that is setgid (g+s)
|
||||
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
|
||||
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
|
||||
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
|
||||
# This is for files with execute permission:
|
||||
exec 01;32
|
||||
# List any file extensions like '.gz' or '.tar' that you would like ls
|
||||
# to colorize below. Put the extension, a space, and the color init string.
|
||||
# (and any comments you want to add after a '#')
|
||||
# If you use DOS-style suffixes, you may want to uncomment the following:
|
||||
#.cmd 01;32 # executables (bright green)
|
||||
#.exe 01;32
|
||||
#.com 01;32
|
||||
#.btm 01;32
|
||||
#.bat 01;32
|
||||
.tar 01;31 # archives or compressed (bright red)
|
||||
.tgz 01;31
|
||||
.arj 01;31
|
||||
.taz 01;31
|
||||
.lzh 01;31
|
||||
.zip 01;31
|
||||
.z 01;31
|
||||
.Z 01;31
|
||||
.gz 01;31
|
||||
.bz2 01;31
|
||||
.deb 01;31
|
||||
.rpm 01;31
|
||||
.jar 01;31
|
||||
# image formats
|
||||
.jpg 01;35
|
||||
.jpeg 01;35
|
||||
.gif 01;35
|
||||
.bmp 01;35
|
||||
.pbm 01;35
|
||||
.pgm 01;35
|
||||
.ppm 01;35
|
||||
.tga 01;35
|
||||
.xbm 01;35
|
||||
.xpm 01;35
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
.png 01;35
|
||||
.mov 01;35
|
||||
.mpg 01;35
|
||||
.mpeg 01;35
|
||||
.avi 01;35
|
||||
.fli 01;35
|
||||
.gl 01;35
|
||||
.dl 01;35
|
||||
.xcf 01;35
|
||||
.xwd 01;35
|
||||
# audio formats
|
||||
.flac 01;35
|
||||
.mp3 01;35
|
||||
.mpc 01;35
|
||||
.ogg 01;35
|
||||
.wav 01;35
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment"># dircolors -p</span>
|
||||
<span class="token comment"># Configuration file for dircolors, a utility to help you set the</span>
|
||||
<span class="token comment"># LS_COLORS environment variable used by GNU ls with the --color option.</span>
|
||||
<span class="token comment"># The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the</span>
|
||||
|
|
@ -204,7 +319,7 @@ STICKY <span class="token number">37</span><span class="token punctuation">;</sp
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199874"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199874"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357221039"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357221039"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,dirname,去除文件名中的非目录部分">
|
||||
<title>dirname 命令,Linux dirname 命令详解:去除文件名中的非目录部分 - Linux 命令搜索引擎</title>
|
||||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1637159199883">
|
||||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1638357221047">
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank" class="github-corner">
|
||||
|
|
@ -57,14 +57,28 @@
|
|||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||||
<p><strong>dirname命令</strong> 去除文件名中的非目录部分,仅显示与目录有关的内容。dirname命令读取指定路径名保留最后一个<code>/</code>及其后面的字符,删除其他部分,并写结果到标准输出。如果最后一个<code>/</code>后无字符,dirname 命令使用倒数第二个<code>/</code>,并忽略其后的所有字符。dirname 和 basename 通常在 shell 内部命令替换使用,以指定一个与指定输入文件名略有差异的输出文件名。</p>
|
||||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||||
<pre class="language-shell"><code class="language-shell">dirname<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dirname(选项)(参数)
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">dirname<span class="token punctuation">(</span>选项<span class="token punctuation">)</span><span class="token punctuation">(</span>参数<span class="token punctuation">)</span>
|
||||
</code></pre>
|
||||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||||
<pre class="language-shell"><code class="language-shell">--help:显示帮助;
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="--help:显示帮助;
|
||||
--version:显示版本号。
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell">--help:显示帮助;
|
||||
--version:显示版本号。
|
||||
</code></pre>
|
||||
<h3 id="实例"><a class="anchor" aria-hidden="true" tabindex="-1" href="#实例"><span class="octicon octicon-link"></span></a>实例</h3>
|
||||
<pre class="language-shell"><code class="language-shell"><span class="token function">dirname</span> //
|
||||
<pre class="language-shell"><div onclick="copied(this)" data-code="dirname //
|
||||
结果为 /
|
||||
|
||||
dirname /a/b/
|
||||
结果为:/a
|
||||
|
||||
dirname a
|
||||
结果为 .
|
||||
|
||||
dirname a/b
|
||||
结果为路径名 a
|
||||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div><code class="language-shell"><span class="token function">dirname</span> //
|
||||
结果为 /
|
||||
|
||||
<span class="token function">dirname</span> /a/b/
|
||||
|
|
@ -101,7 +115,7 @@
|
|||
</div>
|
||||
<script>
|
||||
var _hmt = _hmt || []; (function() {var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?a542c0213a9aa8ae29fccdc8a18b91ef"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1637159199884"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1637159199884"></script>
|
||||
<script type="text/javascript" src="../js/dt.js?v=1638357221047"></script>
|
||||
<script type="text/javascript" src="../js/index.js?v=1638357221047"></script>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue