How to capture standard input from a piped command?

Marc_Sevaux
Fri, 15 May 2020 06:30:36 +0000
General Usage

Apologizes if this has already been answered.
I heavily use command line scripts and combination of piped commands to generate list of numbers that I want to “statistically” analyze by piping them to a julia script.
To be clear and simple, let’s say that I have a file containing numbers and a julia script that calculate the sum of the numbers. I want to call my script in the following way:

cat my_file.dat | julia my_script.jl

and this should display the sum of the numbers.

I’ve seen that I can do that with R in the following way

 cat my_file.dat | R --slave -e 'x <- scan(file="stdin", quiet=TRUE); summary(x)'

but I would love to be able to do it with julia instead.
Thanks in advance for your help.

9 posts - 3 participants