I have result of simple command:
cp -R SourceDir DestDir >out.txt
result="out.txt"
But if script haven't access to write, how I can get output in variable result?
You can just do this:
result=$(cp -R SourceDir DestDir)
You can also use this form:
result=`cp -R SourceDir DestDir`
but this is less preferable for several reasons (see http://mywiki.wooledge.org/BashFAQ/082).
By using backticks (`):
OUTPUT=`cp -R SourceDir DestDir`
Or did I get you wrong?
$(...) should be preferred to backticks; see mywiki.wooledge.org/BashFAQ/082.