Skip to content

lokxii/largs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

largs, the line oriented version of xargs

Motivation

I always want to open the latest file I just downloaded, so I open the terminal and type

ls -t ~/Downloads | head -n1

# Some long file name containing spaces

and I want to pipe that to the open command. The open command on MacOS does not support reading from stdin, so I use xargs. But I can't just pipe to xargs. I have to do this instead

ls -t ~/Downloads | head -n1 | tr '\n' '\0' | xargs -0 open

which sucks.

So I wrote largs.

Usage

usage: ./largs [-ch] [-j replstr] [utility [argument ...]]

It doesn't do a lot of stuff xargs does. But it is enough for my use case.

  • -c Put all input lines into one line of arguments

    ls | largs -c rm
    
    # rm file1 file2 file3...
  • -h Prints help message and exits immediately

  • -j replstr Same as -J in xargs. Defaults to %

Compile

clang++ -std=c++20 -O2 -o largs largs.cpp

or

g++ -std=c++20 -O2 -o largs largs.cpp

or compile with your favourite C++ compiler and specify it to use C++ 20.

You may want to place largs to your $PATH. Maybe /usr/local/bin/

About

The line oriented version of xargs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages