In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.