Conditional / Loop Examples

  [haritaraka12078@cxln4 ~]$ cat>search.txt
Resume - QA/Testing Profile ( ETL / Big Data / Hadoop Testing )
Hi Riya,,,
This is Hari...!
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job.. Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester.
Below I have attached my resume and desired details for your reference.


[haritaraka12078@cxln4 ~]$ pwd
/home/haritaraka12078

--------------------------------------------------------------------------------------------------------
Example
--------------------------------------------------------------------------------------------------------
[haritaraka12078@cxln4 ~]$ cat>script.sh
echo "enter the file name"
read filename
echo "enter the string to search in the file"
read str
                if grep $str $filename
                then
                echo "$str found in the file"
                else
                echo "$str  is not found in the given  file"
                fi


[haritaraka12078@cxln4 ~]$ sh script.sh
enter the file name
search.txt
enter the string to search in the file
Testing
Resume - QA/Testing Profile ( ETL / Big Data / Hadoop Testing )
I am looking for an ETL / Hadoop / Big Data /DWH Testing profile job.. Please let me know if you have any openings regarding ETL / Hadoop / Big Data / DWH Tester.


--------------------------------------------------------------------------------------------------------
Testing found in the file
--------------------------------------------------------------------------------------------------------
[haritaraka12078@cxln4 ~]$ cat>scr1.sh
echo "enter the path"
read path
echo "enter the string to search in the path"
read str
grep -lr $str $path>search-file.txt


[haritaraka12078@cxln4 ~]$ sh scr1.sh
enter the path
/home/haritaraka12078
enter the string to search in the path
Testing

[haritaraka12078@cxln4 ~]$ cat search-file.txt
/home/haritaraka12078/search.txt

--------------------------------------------------------------------------------------------------------
Sum
--------------------------------------------------------------------------------------------------------
[haritaraka12078@cxln4 ~]$ cat>sum.sh
echo "Enter two numners"
read a b
                if [ $a -gt $b ]
                then
                echo "First Number $a is greater value"
                else
                echo "Second Number $b is greater value"
                fi


[haritaraka12078@cxln4 ~]$ sh sum.sh
Enter two numners
5 10
Second Number 10 is greater value

--------------------------------------------------------------------------------------------------------
Date
--------------------------------------------------------------------------------------------------------
[haritaraka12078@cxln4 ~]$ cat>scr3.sh
hour=`date|cut -c 12,13`
if [ $hour -gt 0 -a $hour -le 11 ]
then
echo "good morning"
else
                if [ $hour -gt 12 -a $hour -le 17 ]
                then
                echo "good After Noon"
                else
                echo "good everning"
                fi
fi

[haritaraka12078@cxln4 ~]$ sh scr3.sh
good morning