In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
sort
Row by row unit, the text file for sorting, and output sorting results. By default, each line is compared one unit at a time, starting with the first character and working backwards in ASCII. This command applies to Red Hat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
sort [options] file
sort [OPTION]... --files0-from=F
2. Option list
option
description
--help
Show Help Documentation
--version
output version information
-b
Ignore white space characters at the beginning of each line
-d | --dictionary-order
Only spaces, numbers and English letters are considered when sorting
-f | --ignore-case
Change lowercase letters to uppercase
-g | --general-numeric-sort
Comparison by general value
-i | --ignore-nonprinting
Only ASCII characters between 040 and 176 are considered
-M | --month-sort
Sort by month
-h | --human-numeric-sort
Sort by readable data, e.g. 1K, 2G
-n | --numeric-sort
Sort by numerical size
-R | --random-sort
Random hash sort of keys
--random-source=FILE
Get random bytes from a file
-r | --reverse
reverse arrangement
--sort=WORD
Sort by given requirements: general-numeric -g, human-numeric -h, month -M, numeric -n, random -R, version -V
-V | --version-sort
Sort by version number
--batch-size=NMERGE
Merge NMERGE inputs at most once; use temp files more often
-c | --check | --check=diagnose-first
Check if sorted, not sorted
-C | --check=quiet | --check=silent
As with "-c," don't report the first bad line
--compress-program=PROG
Time compression with prog, decompression with prog-d
--files0-from=F
Reads input from the file specified by the name ending in NUL in file F; if F is-, reads the name from standard input.
-k | --key=POS1[,POS2]
Start key at POS 1(start 1), End key at POS 2(default end of line)
-m | --merge
Merge sorted files without sorting
-o | --output=file
Output results to specified file
-s | --stable
Stabilize sorting by disabling the last comparison
-S | --buffer-size=SIZE
Main memory buffer usage SIZE
-t | --field-separator=SEP
Use sep instead of delimiter
-T | --temporary-directory=DIR
Use DIR for temporary directories instead of $TMPDIR or/tmp; multiple options specify multiple directories
-u, --unique
Use with "-c" to check for strict ordering; if there is no-c, only the first of the same runs is output.
-z, --zero-terminated
End line 0 bytes, not newline
3. Examples
1) Direct sorting
[root@192 weijie]# cat 1.c
1K
1M
1G
1T
[root@192 weijie]# sort 1.c //Direct comparison character sort
1G
1K
1M
1T
2) Sort by readable units
[root@192 weijie]# sort -h 1.c //The contents of the file are sorted in units, which are obviously memory size units
1K
1M
1G
1T
3) Sort by number
[root@192 weijie]# cat 2.c
123
23
212
[root@192 weijie]# sort 2.c //Default sort, compare character by character
123
212
23
[root@192 weijie]# sort -n 2.c //Sort content as a number
23
123
212
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.