You could use Bash redirection :
command 1> /.../path_to_file
=> to redirect stdout into path_to_file.
command > /.../path_to_file
is a shortcut of the previous command.
command 2> /.../path_to_file
=> to redirect stderr into path_to_file
To do both at the same time to the same output: command >/.../path_to_file 2>&1
.
2>&1
means redirect 2
(stderr) to 1
(stdout which became path_to_file).
You could replace path_to_file
by /dev/null
if you don't want to retrieve the output of your command.
Otherwise, you could also store the output of a command :
$ var=$(command) # Recent shell like Bash or KSH
$ var=`command` # POSIX compliant
In this example, the output of command
will be stored in $var
.