Good day everyone. I'm completely new to scripting. I'm trying to practice in it. I'm using Bash on a SuseLinux 10.3 box. I want to practice by sort of creating my own simple IP Monitoring app that will notify me when somethings down.

That said, here's my first simple but seemingly impossible obstacle.

I have found and understand how to redirect a command's output to a file. For instance, ./fping > test.

That works and I appreciate that. But what about if I want to send the return to a variable for processing instead? How do I do this?

I tried ./fping > $test and then, on the second line, echo $test, but this did not work. It told me that it was an ambiguous redirect.

Thank you for any help you can provide.


9 Years
Discussion Span
Last Post by eggi

Also, if it helps, your original redirect


was a redirect to value of the variable test, which may not have been defined, giving you the ambiguous redirect error. In most shell languages, use

variable (when defining the variable)


$variable (when you want to access its value)

Best wishes,


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.