i have a shell script “script.sh” which gives output as “success” or “Failed” when i execute in unix window.
Now i want to store the output of script.sh into a unix command variable. say $a = {output of script.sh}
i have a shell script script.sh which gives output as success or Failed when
Share
Two simple examples to capture output the
pwdcommand:or
The first way is preferred. Note that there can’t be any spaces after the
=for this to work.Example using a short script:
then:
In general a more flexible approach would be to return an exit value from the command and use it for further processing, though sometimes we just may want to capture the simple output from a command.