Can someone help explain the following:
If I print:
a=`ls -l`
Then the output of the ls command is stored in the variable a
but if I try:
a=`sh ./somefile`
The result is displayed in the shell ( stdout ), not the variable a
What I expected was the result of a shell trying to execute somefile 'script, which will be stored in a variable.
Please indicate what is wrong with my understanding and a possible way to do this.
Thanks.
EDIT:
Just for clarification, the script ' somefile ' may or may not exist. If he is exsists, then I want the script output to be stored in ' a '. If not, I want the error message "no such file or dir" to be stored in " a "
scripting bash shell
Roman m
source share