LINUX CUT命令的介绍
学习啦在线学习网LINUX CUT命令的介绍
使用cut命令获取文档中的某一列的数据,例如下面的文件cut.tab中间使用tab键分隔,这里要想只显示第3个列区域的内容,可以使用 cut -f3 cut.tab实现。下面学习啦小编就跟大家说说LINUX CUT命令的说明,欢迎大家阅读!!!
LINUX CUT命令的介绍
学习啦在线学习网 1用命令vi cut.tab创建一个cut.tab的文件
2在cut.tab文件中输入如下内容,单词之间用tab作为分隔符。
3输入:wq保存,并退出
4cat查看cut.tab文件的所有内容
学习啦在线学习网 [lele@Oracle ~]$ cat cut.tab
one two three four five six seven
one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
学习啦在线学习网 one two three four five six seven
one two three four five six seven
one two three four five six seven
学习啦在线学习网 one two three four five six seven
5使用cut命令,带上-f参数,例如下面是要查看cut.tab文件的第3列的内容
学习啦在线学习网 [lele@Oracle ~]$ cut -f3 cut.tab
three
three
three
three
three
three
three
three
three
three
three
three
three
three
three
three
three
three
three
学习啦在线学习网 参数-f3的意思就是以tab键的空格为分隔符,截取第3段
6用cat cut.tab查看文件中的内容,如果不保存,最后输入:q即可退出。