bash Tips

 
Written By Sanjir Habib On Dec-6th, 2017

If

if [ [ $1 ]]  
then  
    echo Hello $1  
else  
    echo Provide name  
fi  

and= or=

[ condition ] && var=value_when_true || var=value_when_false  

For Loop

# from..upto..step  
for i in {0..10..2}  
do 
    echo "Welcome $i times"  
done  

Sub-String

# skip 3 + take 4  
u="is WORD a"  
echo "${u:3:4}"  

more to be added…