GrayJack / coreutils

Core utils re-implementation for UNIX/UNIX-like systems written in Rust
Mozilla Public License 2.0
106 stars 40 forks source link

Uniq: Implement -f option #122

Closed marcospb19 closed 3 years ago

marcospb19 commented 4 years ago

Description:

Implement -f/--skip-fields to Uniq.

From the standard:

-f fields Ignore the first fields fields on each input line when doing comparisons, where fields is a positive decimal integer. A field is the maximal string matched by the basic regular expression: [[:blank:]]*[^[:blank:]]*

If the fields option-argument specifies more fields than appear on an input line, a null string shall be used for comparison.


Obs: I did not implemented in #121 because I could not understand while testing with GNU Coreutils' Uniq how this works.

When I called:

uniq -c -f 1 << EOF       
a b
c b
EOF

I expected:

      2 b

But instead, I got:

      2 a b
marcospb19 commented 4 years ago

Hey, @GrayJack, assign me for this! :smile:

I'm focusing in one of my personal projects, but I'm planing to implement it in october, is it alright?

marcospb19 commented 4 years ago

I understood how it works heheh.

image

It ignores the comparison of the first fields, but displays the text of the first one.

GrayJack commented 4 years ago

Yes, I can!! Np

marcospb19 commented 4 years ago

Hahahah you just guessed that I want the hacktoberfest t-shirt :eyes:.

GrayJack commented 4 years ago

LOL, no, I have to put this label on other issues as well, last year hacktoberfest brought a lot of contributions!! It was super nice and fun

marcospb19 commented 3 years ago

Done :D #131