How to use the cut command to intercept file information in Linux

  

In many Linux commands, the cut command can be used to intercept file information and intercept Linux strings. The following is a detailed introduction to the usage of the cut command. Interested friends can learn. under.

The cut command has an interception meaning, which can read content from a linux file or standard input and intercept a text interception tool of the required information column vertically. Cut can help us cut out the required information items, let us analyze the data in the server, simplify the data when the system is eliminated, reduce the work cost and improve the work efficiency! In addition to cut, there are also awk, sed, sort commands can also do interception.

Use of cut format:

cut OPTION option + [FILE] Text or information to be exported

Commonly used options are:

- d: Indicates what is used as a separator to cut. The default is a space.

-f: Which items to select for output, such as: f1 indicates the first item cut,

is as follows Figure; before /etc /passwd 10-user information

If you want to extract information the user name and the user's home directory, you can pass head /etc /passwd |  cut -d: -f1,6

-d: expressed in a colon delimiter, -f1,6 indicating the selection column 1 and column 6 outputs

rear partition

The above The use of the cut command in Linux is introduced. Using the cut command to intercept a string can reduce the workload and improve the work efficiency. Of course, you can also use other commands such as the sed command, the effect is the same.

Copyright © Windows knowledge All Rights Reserved