Hi all,
Can someone help explain the following:
If I type:
a=`ls -l`
Then the output of the ls command is saved in the variable a
but if I try:
a=`sh ./somefile`
The result is outputed to the shell (stdout
) rather than the variable a
What I expected was the result operation of the shell trying to execute a scrip 'somefile
' to be stored in the variable.
Please point out what is wrong with my understanding and a possible way to do this.
Thanks.
EDIT:
Just to clarify, the script 'somefile
' may or may not exist. If it exsists then I want the output of the script to be stored in 'a
'. If not, I want the error message "no such file or dir" stored in 'a
'