About 50 results
Open links in new tab
  1. What is the difference between "sort -u" and "sort | uniq"?

    56 One difference is that uniq has a number of useful additional options, such as skipping fields for comparison and counting the number of repetitions of a value. sort 's -u flag only implements the …

  2. Sort and count number of occurrence of lines

    Nov 26, 2014 · uniq options: -c, --count prefix lines by the number of occurrences sort options: -n, --numeric-sort compare according to string numerical value -r, --reverse reverse the result of …

  3. How to get only the unique results without having to sort data?

    62 $ cat data.txt aaaaaa aaaaaa cccccc aaaaaa aaaaaa bbbbbb $ cat data.txt | uniq aaaaaa cccccc aaaaaa bbbbbb $ cat data.txt | sort | uniq aaaaaa bbbbbb cccccc $ The result that I need is to display …

  4. Difference between sort -u and uniq -u - Unix & Linux Stack Exchange

    May 30, 2022 · The question is: is the output of sort -u |wc the same as uniq -u |wc? Because they don't yield the same results. The manual for uniq specifies: -u, --unique only print unique lines My output …

  5. uniq - finding all non-unique lines in a file - Unix & Linux Stack Exchange

    Nov 7, 2019 · 2 I'm trying to use uniq to find all non-unique lines in a file. By non-unique, I mean any line that I have already seen on the previous line. I thought that the "-D" option would do this: -D print all …

  6. Why doesn't "uniq --unique" remove all duplicate lines?

    Jul 16, 2021 · uniq requires the input to be sorted (from man uniq) if you want it to remove all duplicate lines: DESCRIPTION Filter adjacent matching lines from INPUT (or standard input), writing to …

  7. How to take only uniq rows based on a column using linux cmd?

    Oct 28, 2021 · The output of uniq is then passed to grep and used as a series of regular expressions to search for in the input file. This solution will likely break if your input file contains certain regular …

  8. Difference between cat file.txt | sort -u and cat file.txt | uniq

    Aug 25, 2019 · 5 Strictly speaking, uniq doesn't need sorted input - but it is true that uniq will only remove consecutive duplicate lines. The difference is that: sort sorts a file and (using its -u option) …

  9. How to print only the duplicate values from a text file?

    You can use uniq(1) for this if the file is sorted: uniq -d file.txt If the file is not sorted, run it through sort(1) first: sort file.txt | uniq -d This will print out the duplicates only. Technically the input does not need to …

  10. Printing unique lines - Unix & Linux Stack Exchange

    Mar 22, 2011 · Is there some better solution for printing unique lines other than a combination of sort and uniq?