I have a command line utility from a third party (it’s big and written in Java) that I’ve been using to help me process some data. This utility expects information in a line delimited file and then outputs processed data to STDOUT.
In my testing phases, I was fine with writing some Perl to create a file full of information to be processed and then sending that file to this third party utility, but as I’m nearing putting this code in production, I’d really prefer to just pipe data to this utility directly instead of first writing that data to a file as this would save me the overhead of having to write unneeded information to disk. Is there any way to do this in unix?
Currently I call the utility as follows:
bin/someapp do-action --option1 some_value --input some_file
I’d like to do something like:
bin/someapp do-action --option1 some_value --input $piped_in_data
Is anything like that possible without my modifying the third party app?
You should be able to use /dev/stdin:
(Note that on some systems, /dev/stdin is a symlink; if your Java program doesn’t cope with that, you might have to use /dev/fd/0 or something similar instead.)