cut
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
cut options [files]
Cut out selected columns or fields from one or more files. In the following options, list is a sequence of integers. Use a comma between separate values, and a hyphen to specify a range (e.g., 1-10,15,20 or 50-). See also paste and join.
Options
Specify list of positions; only bytes in these positions will be printed.
Cut the column positions identified in list. Column numbers start with 1.
Use with -f to specify field delimiter as character c (default is tab); special characters (e.g., a space) must be quoted.
Cut the fields identified in list.
Don't split multibyte characters.
Use with -f to suppress lines without delimiters.
Use string as the output delimiter. By default, the output delimiter is the same as the input delimiter.
Print help message and exit.
Print version information and exit.
Examples
Extract usernames and real names from /etc/passwd:
cut -d: -f1,5 /etc/passwd
Find out who is logged on, but list only login names:
who | cut -d" " -f1
Cut characters in the fourth column of file, and paste them back as the first column in the same file:
cut -c4 file | paste - file