Coder Social home page Coder Social logo

ysf / anewer Goto Github PK

View Code? Open in Web Editor NEW
57.0 4.0 4.0 57 KB

anewer appends lines from stdin to a file if they don't already exist in the file. This is a rust version of https://github.com/tomnomnom/anew

Home Page: https://github.com/ysf/anewer

License: GNU General Public License v3.0

Rust 100.00%
cli bugbounty tool uniq rust stdin stdout

anewer's Introduction

anewer crates.io @ysfr

anewer appends lines from stdin to a file if they don't already exist in the file. You could also use it as uniq without sort. This is a rust version of tomnomnom/anew. It makes use of tkaitchuck/aHash to cut down runtime to ~50%. Since only hashed lines are held in memory, it cuts down memory usage for inputs with long lines. Which is similar how huniq works.

Usage

$ anewer -h
USAGE:
    anewer [FLAGS] [filename]

FLAGS:
    -n, --dry-run    Dry run, will leave the file as it is
    -h, --help       Prints help information
    -v, --invert     Invert the sense of matching
    -q, --quiet      Quiet, won't print to stdout
    -V, --version    Prints version information

ARGS:
    <filename>

Installation

cargo install anewer

Add unknown elements of newthings.txt to things.txt

$ cat things.txt
Zero
One
Two

$ cat newthings.txt
One
Two
Three
Four

$ cat newthings.txt | anewer things.txt
Three
Four

$ cat things.txt
Zero
One
Two
Three
Four

Or use it as simple uniq without sort

$ cat list.txt
One
One
Two
Two
Three
Four
Three
Four

$ cat list.txt | anewer
One
Two
Three
Four

License

GPLv3+

anewer's People

Contributors

anthraxx avatar kpcyrd avatar stoeckmann avatar ysf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

anewer's Issues

Add option to open [filename] with O_CREAT

by default, anew opens file with O_CREAT. despite liking anewer's behavior of failing i file doesn't exist, it would be nice to have a flag -c, --create to be able to ask anewer to create the file if it doesn't exist yet

Invert

@ysf It would be good if it have invert match functionality too which is not in anew.

[FEATURE] Implement flock(2) advisory locks on linux

Hi ! After posting this tweet, @sn0int mentioned anewer tool, which is an awesome, modern replacement for anew.

My feature request is about supporting advisory locks flock(2) on linux. Indeed, when 2 instances of anew/anewer try to write to the same file, both may end up using an outdated hashmap, and then allowing to add duplicate results to the file.

Implementing flock on the opened file would prevent this.

I understand that it may sound overkill, and i don't know if it's easy to implement in rust

Easily allow disregarding timestamps, etc.

Of course that can be done with filters before, but it would be easier to be able to specify an option to e.g., ignore changed numbers or timestamp-like data.

I assume simply regexp-changing the string to hash will allow that. It would only need to find nice regular expressions for some common filters.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.