Cut-and
The Cut command extracts text columns from a text file or text stream.
Cut syntax
[root@www ~]# cut-d ' delimited character '-f fields <== used with specific separator characters
[root@www ~]# cut-c character interval <== for neat information
options and Parameters:-
D : followed by a separator character. Used in conjunction with-
F : Splits a piece of information into several paragraphs with-D, using-F to remove the meaning of paragraph,-
C : The fixed character interval is taken out of the unit of character (characters);
The PATH variable is as follows
[Root@www ~]# echo $PATH
/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/x11r6/bin:/usr/games
# 1 | 2 | 3 | 4 | 5 | 6 | 7
Take the path variable out and I'll find the fifth path.
#echo $PATH | Cut-d ': '-F 5
/usr/local/bin
Take the path variable out and I'll find the third and fifth paths.
#echo $PATH | Cut-d ': '-F 3,5
/sbin:/usr/local/bin
Take the path variable out and I'm going to find the third to the last path.
echo $PATH | Cut-d ': '-f 3-
/sbin:/usr/sbin:/usr/local/bin:/usr/x11r6/bin:/usr/games
Take the path variable out and I'm going to find the first to the third path.
#echo $PATH | Cut-d ': '-f 1-3
/bin:/usr/bin:/sbin:
Take the path variable out, I'm going to find the first to third, and the fifth path.
echo $PATH | Cut-d ': '-f 1-3,5
/bin:/usr/bin:/sbin:/usr/local/bin
Practical example: Show only the/etc/passwd user and Shell
#cat/etc/passwd | Cut-d ': ' F 1,7
root:/bin/bash
daemon:/bin/sh
bin:/bin/sh
Source: http://www.cnblogs.com/zwgblog/p/6006102.html