Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging identical lines in an output

I'm trying to merge or not repeat the lines in an output using bash but don't want to grep for it. I'm not sure how to do it. I'm trying to do this in Linux:

Before:

113.171.10.13
113.171.10.13
113.171.10.13
113.171.10.13
23.253.228.76
23.253.228.76
23.253.228.76
23.253.228.76
23.253.228.76
23.253.228.76

After:

113.171.10.13
23.253.228.76

Any help is appreciated!

Thanks!

like image 676
Joe Avatar asked Dec 14 '25 13:12

Joe


1 Answers

Use unique sort, outputing only the first of an equal run:

sort -u
like image 159
rodrigomelo Avatar answered Dec 18 '25 08:12

rodrigomelo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!