user3565150
user3565150

Reputation: 914

Unix script file redirection

I have a shell script written to execute tests in regression (Do_regr.sh). If I give the option -l then it displays the ip addresses of machines where regression can be run. (Do_regr.sh -l)

I want to store this output in a text file. But redirection is not working for the script. If I give Do_regr.sh -l > host_names, I see host_names is empty but the names are displayed on the screen.

What is the correct command to do this ?

Upvotes: 1

Views: 32

Answers (1)

anubhava
anubhava

Reputation: 785128

Script must be writing it on stderr instead of stdout. Use this redirection to redirect both stdout and stderr:

Do_regr.sh -l >& host_names

Upvotes: 1

Related Questions