You are not logged in.

#1 2022-02-05 18:44:07

ib
Member
Registered: 2021-12-11
Posts: 25

uniq doesn't delete more than 4 lines

I am writing a program for arch linux and I need to understand what is going on with the uniq command and my file.
File: https://www.toptal.com/developers/haste … uhoqi.yaml
My command of script:

cat file | uniq -cd

output:

      4 WAIT

I can't figure out what the problem is please help

Offline

#2 2022-02-05 18:54:45

Daerandin
Member
From: Norway
Registered: 2013-05-07
Posts: 253
Website

Re: uniq doesn't delete more than 4 lines

sort file | uniq -cd

Offline

#3 2022-02-05 19:26:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,538
Website

Re: uniq doesn't delete more than 4 lines

Also, as there is only one thing repeated, if you actually know what it will be beforehand just use grep:

grep -c WAIT file

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2022-02-05 20:13:02

Awebb
Member
Registered: 2010-05-06
Posts: 6,048

Re: uniq doesn't delete more than 4 lines

man uniq

"Note: 'uniq' does not detect repeated lines unless they are adjacent.  You may want to sort the  input  first, or use 'sort -u' without 'uniq'."

Offline

Board footer

Powered by FluxBB