In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
sort overview
Sort is a tool for sorting file content by behavior unit, and also by different data types. For example, data and character cards are different. The syntax of the sort command is "sort [options] parameter," and common options include the following.
-f: Ignore case;-b: Ignore spaces before each line;-M: Sort by month;-n: Sort by number;-r: Sort in reverse;-u: Equivalent to uniq, indicating that only one line of the same data is displayed;-t: Specify a separator, separated by the [Tab] key by default;-o: Transfer sorted results to a specified file;-k: Specify a sorting region. Example 1: Sort accounts in/etc/passwd file [root@localhost ~]# sort /etc/passwdabrt:x:173:173::/etc/abrt:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin apache:x:48:48:Apache:/var/www:/sbin/nologinbin:x:1:bin:/bin:/sbin/nologin... Example 2: Reverse the third column in the/etc/passwd file. [root@localhost ~]# sort -t ':' -rk 3 /etc/passwd nobody:x:99:99:Nobody:/:/sbin/nologinpostfix:x:89:89:::/var/spool/postfix:/sbin/nologindbus:x:81:81:System message bus:/:/sbin/nologinmail:x:8:12:mail:/var/spool/mail:/sbin/nologin Example 3: Sort the third column in the/etc/passwd file and save the output to the user.txt file. [root@localhost ~]# sort -t ':' -k 3 /etc/passwd -o user.txt [root@localhost ~]# cat user.txt root:x:0:0:root:/root:/bin/bash uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologinoperator:x:11:0:operator:/root:/sbin/nologinuniq Tool Overview
The Uniq tool is commonly used in Linux systems in conjunction with the sort command to report or ignore duplicate lines in files. The specific command syntax format is uniq [options] parameter. Common options include the following.
-c: count;-d: display only duplicate rows;-u: display only rows that occur once; example 1: delete duplicate rows from testfile file. [root@localhost ~]# cat testfile Linux 10Linux 20Linux 30 Linux 30CentOS 6.5CentOS 6.5CentOS 7.3CentOS 7.3[root@localhost ~]# uniq testfile Linux 10Linux 20Linux 30CentOS 6.5CentOS 7.3 Example 2: Remove duplicate lines from testfile and display the number of times the line is repeated at the beginning of the line. [root@localhost ~]# uniq -c testfile 1 Linux 101 Linux 203 Linux 303 CentOS 6.53 CentOS 7.3 Example 3: Find duplicate lines in the testfile file. [root@localhost ~]# uniq -d testfile Linux 30CentOS 6.5CentOS 7.3sort can put discontinuous to heavy uniq can only go heavy continuous thanks for reading!!!
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.