Twitter Updates

Tuesday 28 October 2008

Display command output from bash script

To directly display the output from a command in a bash script (do not forget to set executable on the file $chmod u+x bashtest.sh) Where bashtest.sh is the name of the script file.

#!/bin/bash

#List home directory (note the back ticks)
echo `ls -l ~`

#Store command output as a variable
i=`ls -l ~`
echo $i

No comments: