Command | Description |
---|---|
ipconfig | to show network address details |
date | to show current date |
cal | to show current month calender |
top | to moniter all process |
ps | current user process |
ps | aux username- process of particular user |
pwd | present work directory |
Script Command | Description |
---|---|
sh scriptname.sh | to run the script |
cat scriptname.sh | to display the script content |
vi welcome.sh | to open script in vi editor |
Note: a=10 not as a = 10 //space not allowed, will taken as seperate commands
a=”rajesh rockz” not as a=rajesh rockz //need double quotes
#! /bin/bash
echo "hello $LOGNAME"
echo "The host name is `hostname`"
echo "the current working directory is `pwd`"
at 00:47 //command wil execute at 00:47 min hour dayofmonth month dayofweek process-code
is a symbolic name of a defined value
Ex. a=10 "a"=symbolic_value 10=value
Note: to read value, we need to put $a
Types of Variable:
Export variables: export varname=value sh root/root/scriptpath.sh Unchanged variable: varname=value readonly varname Lenght of value: ${#varname}
read -p “please enter name” varname
read -sp “please enter password” varname //s for silent
declare -i varname
+-*/% **-exponential Let: allow simple arithmetic expression let a=a+1
expr 1 + 1 //result 2 expr 2 * 3 should have space, not as 1+1
$[a + b] or $((a ** b))
&&- both sides should execute
|| second side never executed until it is true
if [ "$a" == "yes" ]
then
command or code
else
command or code
fi
if [condition]
then
command or code
elif[condition]
then
command or code
else
command or code
fi
case $choice_var in
a)
echo "first value"
;;
b)
echo "second value"
;;
*)
echo "this is default"
;;
esac