read piped info into a script

Bash shell is the common linux command language.
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

read piped info into a script

Post 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?
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: read piped info into a script

Post 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
Post Reply