Beruflich Dokumente
Kultur Dokumente
>>ADD
Syntax: expr 20 + 10
Output: 30
>>SUB
Syntax: expr 20 - 10
Output: 10
>>MULTIPLY
Syntax: expr 20 \* 10
Output: 200
>>DIVISION
Syntax: expr 20 / 10
Output: 2
USING VARIABLE
>>ADD
Syntax:
NUM1=50
NUM2=30
echo $NUM1+$NUM2
Output: 80
>>Command: let
--------
>>>IF STATEMENT
Syntax:
MYNUM=100
---------
if [ -f /root/file1 ]
then
echo "The file1 exists."
else
echo "The file1 does not exists."
fi
>>>WHILE LOOP
myvar=1
>>>CASE STATEMENT
read fruite;
case $fruite in
1)echo "You choose Mango";;
2)echo "You choose Apple";;
3)echo "You choose Jackfruite";;
4)echo "You choose Orange";;
*)echo "You choose something else";;
esac
read command;
case $command in
1)echo -e "You choose ls \n output is"
ls;;
2)echo -e "You choose df -h \n output is"
df -h;;
3)echo -e "You choose du -sh \n output is"
du -sh;;
*)echo -e "You choose something else";;
esac
----------------
row=1
for GETVALUE in net.ipv4.conf.all.accept_redirects
net.ipv4.conf.default.accept_redirects net.ipv4.conf.all.secure_redirects
net.ipv4.conf.default.secure_redirects
do
echo "Running process $row of 4"
krnl=`grep $GETVALUE /etc/sysctl.conf`
if [ "$krnl" == "$GETVALUE = 0" ]; then
echo -e "\t Protection was << DISABLED >>"
`sed -i s/"$GETVALUE = 0"/"$GETVALUE = 1"/g /etc/sysctl.conf`
echo -e "\t Protection is now << ENABLED >>"
elif [ "$krnl" == "" ]; then
echo -e "\t Protection << NOT FOUND >>"
`echo "$GETVALUE = 1" >> /etc/sysctl.conf`
echo -e "\t Protection is now << ENABLED >>"
else
echo -e "\t Protection is already << ENABLED >>"
fi
row=$(( $row+1 ))
done