Browse > Home / Hacks, 软件架构 / Blog article: Linux秘笈25.Linux的Cut命令

| 订阅RSS

Linux秘笈25.Linux的Cut命令

三月 18th, 2009 Posted in Hacks, 软件架构

Cut command can be used to display only specific columns from a text file or
other command outputs.
Following are some of the examples.
Display the 1st field (employee name) from a colon delimited file

  $ cut -d: -f 1 names.txt
  Emma Thomas
  Alex Jason
  Madison Randy
  Sanjay Gupta
  Nisha Singh

Display 1st and 3rd field from a colon delimited file

  $ cut -d: -f 1,3 names.txt
  Emma Thomas:Marketing
  Alex Jason:Sales
  Madison Randy:Product Development
  Sanjay Gupta:Support
  Nisha Singh:Sales

Display only the first 8 characters of every line in a file

  $ cut -c 1-8 names.txt
  Emma Tho
  Alex Jas
  Madison
  Sanjay G
  Nisha Si

相关文章

2 Responses to “Linux秘笈25.Linux的Cut命令”

  1. deepblue Says:

    先展示一下names.txt文件的内容,可能会更清楚一些


  2. jcai Says:

    呵呵,的确是


Leave a Reply