Sample Header Ad - 728x90

Skip line from console if equal than line before, adding count (in realtime)

-1 votes
1 answer
124 views
Using uniq it is possible to filter out sequential duplicate lines. while (true) do echo 1; echo 2; echo 2; echo 1; sleep 1; done | uniq becomes: 1 2 1 Is there a way to have duplicated sequential lines removed, while adding the number of repetitions? E.g. in the example above 1 2 (2) 1 And if a new "1" line arrives, the above should become: 1 2 (2) 1 (2) This is not for a file but for a stream (such as tail -f), where new lines are being added in real time.
Asked by Jose Gómez (101 rep)
Jan 25, 2022, 01:49 PM
Last activity: Jan 25, 2022, 06:33 PM