Getting started with Linux shell scripts--cut command
Cut
The Cut command extracts text columns from a text file or text stream.
Cut grammar
[[email protected] ~]# Cut- D " Delimited character " -F fields <== for having a specific delimiter character [[ Email protected] ~] # cut - C-character interval <== for neatly arranged information options and Parameters: -d: followed by delimited characters. Used in conjunction with -F; -f: Divides a piece of information into segments by -d, with -f take out the meaning of paragraph;-C: Remove the fixed-character interval in units of characters (characters);
The PATH variable is as follows
[[Email protected] ~]# Echo $PATH/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/x11r6/bin: /usr/Games# 1 | 2 | 3 | 4 | 5 | 6 | 7
To take the path variable out, I'm going to find a fifth path.
#':5/usr/local/bin
Take the path variable out and I'll find the third and fifth paths.
#Echocut':'3,5/sbin:/usr/local/bin
Take the path variable out and I'll find the third to last path.
':-F 3-
/SBIN:/USR/sbin:/usr/local/bin:/usr/x11r6/bin:/usr/games
Take the path variable out and I'll find the first to third path.
#':1-3
/BIN:/USR/bin:/sbin:
Take the path variable out, I want to find the first to third, there is a fifth path.
':-f 1-3,5
/BIN:/USR/bin:/sbin:/usr/local/bin
Practical Example: Display only/etc/passwd users and shells
':1,7 root:/bin/bashdaemon:/bin/shbin:/bin/sh
Getting started with Linux shell scripts--cut command