tomnomnom / anew

A tool for adding new lines to files, skipping duplicates
MIT License
1.34k stars 147 forks source link

The Upside-anew #7

Closed leesoh closed 2 years ago

leesoh commented 4 years ago

I love how anew works. I often find myself doing this, though:

cat things.txt | grep -v -f thingsidontwant.txt | t2.txt && mv t2.txt things.txt

It would be wonderful if I could do:

cat thingsidontwant.txt | anew -invert things.txt

and have anew REMOVE any items that match the input from the target file.

I'm happy to take this on but wanted to open an issue first to see if this would be worth a PR or better suited to a standalone tool.

ruevaughn commented 3 years ago

That seems like a really good idea to me. Let me know if you want help on it and i'll fork it and give it a go.

ruevaughn commented 3 years ago

By using the inverse it makes it so it outputs all the duplicates. I haven't ran into a need for that yet, but I can see how that could be helpful. I am however needing a flag to control the output in this scenario:

cat domains1.txt domains2.txt domains3.txt | anew domains | httprobe -c 80

In my case that command had not completed successfully, so even though cat *.txt | anew outputs 5000+ domains, because I added the file argument to anew it sees those already exist so they never get sent to httprobe. So what is similar to your issue is i'm wanting more fine grained control of what is output to the terminal, not necesarily to change how anew is behaving at all.

tomnomnom commented 2 years ago

Thanks both for your input!

@leesoh I kinda feel like that should almost be a separate tool entirely just because it would need to work so differently to anew. I'd be happy to hear about it if you make one!

@ruevaughn to make sure I understand correctly, would a flag that makes anew output everything its given to stdout, but only writes new/non-duplicate values to the file work for your use-case?

leesoh commented 2 years ago

@tomnomnom I completely forgot I had this open and you're completely correct. I ended up writing this as a separate tool: https://github.com/leesoh/hacks/tree/master/untee.

tomnomnom commented 2 years ago

@leesoh ace! I'll take a look at that, thank you!

Also: really nice to see more people with a hacks repo :)