【转贴】cut命令的详细用法

发表于:2007-06-08来源:作者:点击数: 标签:
名称:cut 使用权限:所有使用者 用法:cut-cnum1-num2filename 说明:显示每行从开头算起num1到num2的文字。 范例: shellcatexample test2 thisistest1 shellcut-c0-6example##print开头算起前6个字元 test2 thisi cut其实很有用 -cm-n表示显示每一行的第m

名称:cut
使用权限:所有使用者
用法:cut -cnum1-num2 filename
说明:显示每行从开头算起 num1 到 num2 的文字。
范例:

        shell>> cat example
        test2
        this is test1
        shell>> cut -c0-6 example       ## print 开头算起前 6 个字元
        test2
        this i 

cut其实很有用
-c m-n 表示显示每一行的第m个字元到第n个字元。例如:
---------file----------- 
  liubi  23 14000 
---------file----------- 
# cut -c 3-9,12-20 file 
liubi 14000  

-f m-n 表示显示第m栏到第n栏(使用tab分隔)。例如: 
---------file----------- 
liubi  23  14000 
---------file----------- 
# cut -f 1,3 file 
liubi 14000

【发表回复】【查看CU论坛原帖】【添加到收藏夹】【关闭】

原文转自:http://www.ltesting.net