The output of a command can be assigned to a variable,
VarName=$(command)
#!/bin/bash
LS_OUT=$(ls)
echo $LS_OUT
Or
#!/bin/bash
#the 'date' command retrieves the current date(many options)
DOW=$(date +%a) #get day of week
MONTH=$(date +%b)
DAY=$(date +%d)
YEAR=$(date +%Y)
echo "Today is ${DOW} ${MONTH}-${DAY}-${YEAR}"
$ alias today="./today.sh"
$ today
Today is Wed Oct-17-2007
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment