mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2026-03-05 13:16:56 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
<p>说明:该命令有两项功能,其一是用来显示文件的内容,它依次读取由参数 file 所指 明的文件,将它们的内容输出到标准输出上;其二是连接两个或多个文件,如<code>cut fl f2 > f3</code>将把文件 fl 和 f2 的内容合并起来,然后通过输出重定向符“>”的作用,将它们放入文件 f3 中。</p>
|
||||
<p>当文件较大时,文本在屏幕上迅速闪过(滚屏),用户往往看不清所显示的内容。因此,一般用 more 等命令分屏显示。为了控制滚屏,可以按 Ctrl+S 键,停止滚屏;按 Ctrl+Q 键可以恢复滚屏。按 Ctrl+C(中断)键可以终止该命令的执行,并且返回 Shell 提示符状态。</p>
|
||||
<h3 id="语法">语法</h3>
|
||||
<pre><code>cut(选项)(参数)</code></pre>
|
||||
<pre><code class="language-bash">cut(选项)(参数)</code></pre>
|
||||
<h3 id="选项">选项</h3>
|
||||
<pre><code>-b:仅显示行中指定直接范围的内容;
|
||||
<pre><code class="language-bash">-b:仅显示行中指定直接范围的内容;
|
||||
-c:仅显示行中指定范围的字符;
|
||||
-d:指定字段的分隔符,默认的字段分隔符为“TAB”;
|
||||
-f:显示指定字段的内容;
|
||||
@@ -20,38 +20,38 @@
|
||||
<p>文件:指定要进行内容过滤的文件。</p>
|
||||
<h3 id="实例">实例</h3>
|
||||
<p>例如有一个学生报表信息,包含 No、Name、Mark、Percent:</p>
|
||||
<pre><code>[root@localhost text]# cat test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cat test.txt
|
||||
No Name Mark Percent
|
||||
01 tom 69 91
|
||||
02 jack 71 87
|
||||
03 alex 68 98
|
||||
</code></pre>
|
||||
<p>使用 <strong>-f</strong> 选项提取指定字段(这里的 f 参数可以简单记忆为 <code>--fields</code>的缩写):</p>
|
||||
<pre><code>[root@localhost text]# cut -f 1 test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -f 1 test.txt
|
||||
No
|
||||
01
|
||||
02
|
||||
03</code></pre>
|
||||
<pre><code>[root@localhost text]# cut -f2,3 test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -f2,3 test.txt
|
||||
Name Mark
|
||||
tom 69
|
||||
jack 71
|
||||
alex 68
|
||||
</code></pre>
|
||||
<p><strong>–complement</strong> 选项提取指定字段之外的列(打印除了第二列之外的列):</p>
|
||||
<pre><code>[root@localhost text]# cut -f2 --complement test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -f2 --complement test.txt
|
||||
No Mark Percent
|
||||
01 69 91
|
||||
02 71 87
|
||||
03 68 98
|
||||
</code></pre>
|
||||
<p>使用 <strong>-d</strong> 选项指定字段分隔符:</p>
|
||||
<pre><code>[root@localhost text]# cat test2.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cat test2.txt
|
||||
No;Name;Mark;Percent
|
||||
01;tom;69;91
|
||||
02;jack;71;87
|
||||
03;alex;68;98</code></pre>
|
||||
<pre><code>[root@localhost text]# cut -f2 -d";" test2.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -f2 -d";" test2.txt
|
||||
Name
|
||||
tom
|
||||
jack
|
||||
@@ -71,7 +71,7 @@ alex
|
||||
<li><strong>-f</strong> 表示定义字段。</li>
|
||||
</ul>
|
||||
<p><strong>示例</strong></p>
|
||||
<pre><code>[root@localhost text]# cat test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cat test.txt
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
@@ -79,7 +79,7 @@ abcdefghijklmnopqrstuvwxyz
|
||||
abcdefghijklmnopqrstuvwxyz
|
||||
</code></pre>
|
||||
<p>打印第 1 个到第 3 个字符:</p>
|
||||
<pre><code>[root@localhost text]# cut -c1-3 test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -c1-3 test.txt
|
||||
abc
|
||||
abc
|
||||
abc
|
||||
@@ -87,7 +87,7 @@ abc
|
||||
abc
|
||||
</code></pre>
|
||||
<p>打印前 2 个字符:</p>
|
||||
<pre><code>[root@localhost text]# cut -c-2 test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -c-2 test.txt
|
||||
ab
|
||||
ab
|
||||
ab
|
||||
@@ -95,7 +95,7 @@ ab
|
||||
ab
|
||||
</code></pre>
|
||||
<p>打印从第 5 个字符开始到结尾:</p>
|
||||
<pre><code>[root@localhost text]# cut -c5- test.txt
|
||||
<pre><code class="language-bash">[root@localhost text]# cut -c5- test.txt
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
efghijklmnopqrstuvwxyz
|
||||
|
||||
Reference in New Issue
Block a user