Page 1 of 1

read piped info into a script

Posted: Mon May 12, 2014 8:04 pm
by mister_v
Hi,

I would like to read the result from one command into my script using piped.
But I don't know what kind of argument to use.

Can anyone help me with this?

Re: read piped info into a script

Posted: Tue May 13, 2014 7:57 pm
by chris
I think piped info is just as standard input.

Something like this should work

Code: Select all

MESSAGE="$(< /dev/stdin)"
Standard input get stored in variable MESSAGE

You can test the script with this
echo "this is a test" | script.sh