Difference between revisions of "Echo Command"
Jump to navigation
Jump to search
Line 4: | Line 4: | ||
<source lang="bash">printf "%s\n" $varName</source> | <source lang="bash">printf "%s\n" $varName</source> | ||
− | ==Generating Output With echo command= | + | ==Generating Output With echo command== |
Use echo command to display a line of text or variable value. It offer no formatting option. It is good command to display simple output. | Use echo command to display a line of text or variable value. It offer no formatting option. It is good command to display simple output. | ||
===echo Command Examples=== | ===echo Command Examples=== |
Revision as of 19:00, 30 August 2009
To display the value of a variable either use echo or printf command as follows:
echo $varName
OR
printf "%s\n" $varName
Generating Output With echo command
Use echo command to display a line of text or variable value. It offer no formatting option. It is good command to display simple output.
echo Command Examples
#!/bin/bash
# Display welcome message, computer name and date
echo "*** Backup Shell Script ***"
echo
echo "*** Run time: $(date) @ $(hostname)"
echo
# Define variables
BACKUP="/nas05"
NOW=$(date +"%d-%m-%Y")
# Let us start backup
echo "*** Dumping MySQL Database to $BACKUP/$NOW..."
# Just sleep for 3 secs
sleep 3
# And we are done...
echo
echo "*** Backup wrote to $BACKUP/$NOW/latest.tar.gz"