2024年5月28日发(作者:)

linux过滤命令(Linux filter command)

Cut?

Cut isn't that "cut"? Yes! This instruction can cut a paragraph

of a message to him. The message is "line"! Let's talk about

it next

[root@linux cut -d'~]# separator character' -f fields

[root@linux cut -c ~]# character interval

Parameter:

-d: followed by separate characters. Used with -f;

-f: divide a message into segments according to the -d separator

character, and extract the first paragraph by -f;

-c: take out the fixed character range in units of characters

(characters);

Example:

Example 1: take out the PATH variable, and I'll find the third

path.

[root@linux echo $PATH ~]#

/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin

:/usr/games:

[root@linux echo $PATH cut -d ~]# | ':' -f 5

Hey #! As a result, the directory name of /usr/local/bin

appears!

# because we are in: as a separator, the fifth is

/usr/local/bin!

# so if you want to list the third and fifth? That's the way

it is:

[root@linux echo $PATH cut -d ~]# | ':' -f 3,5

Example two: export the output of the message to obtain twelfth

characters after all strings

[root@linux export ~]#

Declare -x HISTSIZE= "1000""

Declare -x INPUTRC= "/etc/inputrc""

Declare -x KDEDIR= "/usr""

Declare -x LANG= "zh_5""

[root@linux export cut -c 12- ~]# |

HISTSIZE= "1000""