check exit status of scripts or commands
commands/scripts exit status stored in $? variable
ret=$?
if [ $ret -eq 0 ];then
echo "script/command success!"
else
echo "script/command failed"
fi
read user input from console
read input
echo $input
check file exist or not
if[ -f filename]; then
echo "file exist"
fi
check file executable
if[-x filename]; then
echo "file is executable"
fi
timestamp function
datetime() { echo `date "+%Y-%m-%d %H:%M:%S"` ;}
echo "Starting process :" $(datetime)
echo "Ending process :" $(datetime)
date +%D:%T
get count seconds
date +%s like unix time stamp
Some Unix Commands
kill process of a user
pkill -u userid
pkill -u viru
kill a single process
kill -9 pid
find user process
ps -ef | grep userid
find cpu intencive process
top
list file and directory
ls
ll
referances
Advanced Bash-Scripting Guide http://www.faqs.org/docs/abs/HTML/index.html
======================================================================
======================================================================