Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use cut and sort of linux

Shulou Source: shulou.com Published: 2022-06-01 04:52:29 09月25日 Update

This article introduces the relevant knowledge of "how to use cut and sort of linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Cut usage of linux

Cut is a select command that analyzes a piece of data and takes out what we want. Generally speaking, the selected information is usually analyzed according to the "row", not the whole piece of information.

(1) its grammatical format is:

Cut [- bn] [file] or cut [- c] [file] or cut [- df] [file]

instructions

The cut command cuts bytes, characters, and fields from each line of the file and writes them to standard output.

If you do not specify the File parameter, the cut command reads standard input. One of the-b,-c, or-f flags must be specified.

Main parameters

-b: split in bytes. These byte positions ignore multibyte character boundaries unless the-n flag is also specified.

-c: split on a character basis.

-d: custom delimiter, default to tab.

-f: used with-d to specify which area to display.

-n: unsplit multibyte characters. Used only with the-b flag. If the last byte of a character falls within the range indicated by the List parameter of the-b flag, the character will be written out; otherwise, the character will be excluded.

(2) what is the general basis of cut? In other words, how do I tell cut about the clips I want to locate?

The cut command mainly accepts three positioning methods:

First, byte (bytes), with the option-b

Second, the character (characters), with the option-c

Third, fields (domain), with the option-f

Sort usage of linux

The sort command helps us sort according to different data types, its syntax and common parameter formats:

Sort [- bcfMnrtk] [source file] [- o output file]

Additional note: sort can sort the contents of the text file by behavior unit.

Parameters:

-b ignores space characters that begin at the beginning of each line.

-c check whether the files have been sorted in order.

When sorting, uppercase and lowercase letters are ignored.

-M sorts the first three letters according to the abbreviation of the month.

-n is sorted by the size of the number.

-o saves the sorted results to the specified file.

-r is sorted in reverse order.

-t specifies the field delimiter used for sorting.

-k chooses which interval to sort.

This is the end of the content of "how to use cut and sort of linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Characters sorting bytes commands files contents parameters flags units analysis output information size fields letters data more standards formats knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Docker vpn Shulou Information Microsoft