Bash basics: Difference between revisions

From Bitpost wiki
No edit summary
No edit summary
Line 13: Line 13:
$mycmd1 && $mycmd2 && $mycmd3
$mycmd1 && $mycmd2 && $mycmd3
</pre>
</pre>
* To capture output
<pre>myout=`program1 param`;</pre>

Revision as of 20:08, 26 January 2011

Bash certainly has its set of snafus.

  • To store commands in variables:
# NOTE don't put spaces around equals sign!
# NOTE don't use ampersands within command strings, they won't work
# use a blank command if needed, that's fine
mycmd1="command param param"
mycmd2="cmd2 param"
if [ -e /myspecialplace ]
mycmd2=""
fi
mycmd3="cmd3 param"
$mycmd1 && $mycmd2 && $mycmd3
  • To capture output
myout=`program1 param`;