• 要找福利?记不住网址?搜不到?如何与我们保持联系?试试 CTRL+D 把零点博客添加进您的浏览器收藏夹,一键直达永不失联!

Linux colrm命令

linux系统 涛涛 194次浏览 0个评论

Linux colrm命令用于滤掉指定的行。

colrm指令从标准输入设备读取书记,转而输出到标准输出设备。如果不加任何参数,则该指令不会过滤任何一行。

语法

<span class="pln">colrm </span><span class="pun">[开始行数编号<结束行数编号>]</</span><span class="pln">p</span><span class="pun">></span>

<span class="str"><p><b></span><span class="pun">参数说明:<</span><span class="str">/b></</span><span class="pln">p</span><span class="pun">></span>
<span class="str"><ul></span>
<span class="str"><li></span><span class="pun">开始行数编号:</span> <span class="pun">指定要删除的列的起始编号。</</span><span class="pln">li</span><span class="pun">></span>
<span class="str"><li></span><span class="pun">结束行数编号:</span> <span class="pun">指定要删除的列的结束编号,有时候这个参数可以省略。</</span><span class="pln">li</span><span class="pun">></span>
<span class="pun"></</span><span class="pln">ul</span><span class="pun">></span>
<span class="str"><h3></span><span class="pun">实例</</span><span class="pln">h3</span><span class="pun">></span>
<span class="str"><p></span><span class="pun">不带任何参数时该命令不会删除任何列:</</span><span class="pln">p</span><span class="pun">></span>
<span class="str"><pre></span><span class="pln">
colrm</span>

按回车键后,光标将在第一行闪烁,等待标准输入,此时输入字符,如”Hello Linux!”,再按回车键后第二行将出现与第一行相同内容,此时按Ctrl+C组合键可以退出。终端中显示的内容如下所示:

<span class="pln">cmd@hdd</span><span class="pun">-</span><span class="pln">desktop</span><span class="pun">:~</span><span class="pln">$ colrm  
</span><span class="typ">Hello</span> <span class="typ">Linux</span><span class="pun">!</span> <span class="com">#输入Hello Linux!字符串  </span>
<span class="typ">Hello</span> <span class="typ">Linux</span><span class="pun">!</span> <span class="com">#输出刚才输入的字符串Hello Linux! </span>

如想要删除第4 列之后的所有内容,可以使用如下命令:

<span class="pln">colrm </span><span class="lit">4</span>

类似于上例,此时标准输入等待输入,用户输入字符串按回车键后,将输出如下结果:

<span class="pln">cmd@hdd</span><span class="pun">-</span><span class="pln">desktop</span><span class="pun">:~</span><span class="pln">$ colrm </span><span class="lit">4</span>  
<span class="typ">Hello</span> <span class="typ">Linux</span><span class="pun">!</span> <span class="com">#输入Hello Linux!字符串  </span>
<span class="typ">Hel</span> <span class="com">#输出删除了第4列以后所有内容的字符串 </span>

删除指定列的内容。如删除第4列到第6列的内容,可使用如下命令:

<span class="pln">colrm </span><span class="lit">4</span> <span class="lit">6</span>

输出的结果如下:

<span class="pln">cmd@hdd</span><span class="pun">-</span><span class="pln">desktop</span><span class="pun">:~</span><span class="pln">$ colrm </span><span class="lit">4</span> <span class="lit">6</span>  
<span class="typ">Hello</span> <span class="typ">Linux</span><span class="pun">!</span> <span class="com">#输入Hello Linux!字符串  </span>
<span class="typ">HelLinux</span><span class="pun">!</span> <span class="com">#输出删除了从第4列到第6列字符的字符串 </span>

欢迎转载本文:Linux colrm命令
喜欢 (0)
[ld]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址