In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the uniq command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The Linux common command uniq command is used to check and delete repeated rows in text files. It is usually used in conjunction with the sort command, and uniq can check for repeated rows in text files.
Uniq displays or ignores duplicate lines.
Summary uniq [OPTION]... [INPUT [OUTPUT]] is mainly used to write adjacent duplicate lines in the input file (or standard input) to the output file (or standard output).
When there is no option, adjacent duplicate rows are merged into one.
The option-c,-- count increases the number of repeats at the beginning of each line. -d,-- repeated all adjacent duplicate lines are printed only once. -D all adjacent duplicate lines will be printed. -- all-repeated [= METHOD] is similar to-D, but allows groups to be separated by blank lines. The value range of METHOD is {none (default), prepend,separate}. -f,-- skip-fields=N skips the comparison of the first N columns. -- group [= METHOD] displays all rows, allowing each group to be separated by blank lines. Value range of METHOD: {separate (default), prepend,append,both}. -I,-- ignore-case ignores case differences. -s,-- skip-chars=N skips the comparison of the first N characters. -u,-- unique prints only non-adjacent duplicate lines. -z,-- zero-terminated sets the line Terminator to NUL (empty), not the newline character. -w,-- check-chars=N compares only the first N characters of each line. -- help displays help information and exits. -- version displays version information and exits. Parameter INPUT (optional): input file, standard input if not provided.
OUTPUT (optional): output file, standard output when not provided.
A return value of 0 indicates success, while a non-zero value indicates failure.
Note for example: command 2 has the same result as command 3, and command 1 only removes the weight of adjacent lines.
Uniq file.txt sort file.txt | uniq sort-u file.txt displays only a single line. The difference lies in whether to perform sorting:
Uniq-u file.txt sort file.txt | uniq-u counts the number of times each line appears in the file:
Sort file.txt | uniq-c finds duplicate lines in the file:
Sort file.txt | uniq-d Note that uniq only detects whether the adjacent lines are duplicates, and sort-u sorts the input file first and then processes the duplicate lines.
This command is a command in the GNU coreutils package. For help, please see man-s 1 uniq,info coreutils' uniq invocation'.
The above is all the contents of the article "how to use uniq commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.