Get the App
SLTechnology News&Howtos  ›  Servers  › 

Shell fundamentals-2

Shulou Source: shulou.com Published: 2022-06-03 04:15:20 10月05日 Update

1. Cut command

Note: only the results after the operation file are output, and the contents of the file will not be changed.

Cut-d ""-f3jue 6 file

Indicates that columns 3 and 6 are displayed with spaces as delimiters

Cut-d:-f 1BI 3-5 file

Indicates that columns 1 and 3 to 5 are displayed with: as the delimiter

Cut-c n file / / take the nth character

2. Sort command

Usually used in conjunction with the uniq command

Sorting principle: compare the ASCII values of characters or control characters on each line from left to right

1) Summary

The ASCII value of a special symbol is generally less than the ASCII value of a number, and that of a number is less than that of a letter.

2) option

-n is sorted by numeric size; special symbols or letters are treated as the number 0

-r in reverse order in normal order

-t delimiter

3. Uniq command

The condition is: after sorting first, it will be effective to remove the weight.

-c count the number of repetitions

Uniq is equivalent to sort-u

4. Wc command

Option

-l line, count the number of rows

-m statistics of characters

-w word, counting the number of words, how to distinguish separated words? Separated by spaces by default

2mcl.2m is a word.

2mcl is three words.

5. Tee command

1) the tee command redirects the output to the specified file and outputs it to the screen at the same time

2) option

-an append, output append

6. Tr command

For character commands, character replacement commands

7. Split command

For file operations, large files are cut into small files

Option

-b cut the file according to the specified size, and the default file size is bytes

-l cut the file by the specified number of lines

Tags: File command character number statistics output delimiter size sort special letter space symbol line content unit principle byte screen effect Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Shulou Technology Docker Shulou Information