Appearance
语法
cur [options] filename
options
-f
列号,提取第几列。
-d
分隔符,按照指定分隔符分割列,默认是制表符 \t。
-c
按单个字符进行分割,后加数字表示取第几列。
示例
a a a b b b c c c
cut -d " " -f 1 foo.txt cut -d " " -f 2,3 foo.txt
只要第 1 - 4 列 cat /etc/passwd | grep bash$ | cut -d ":" -f 1-4 cat /etc/passwd | grep bash$ | cut -d ":" -f -4
cat /etc/passwd | grep bash$ | cut -d ":" -f 1,6,7
只要第 6 列及之后的列 cat /etc/passwd | grep bash$ | cut -d ":" -f 6-