Grep: Search string in the File from given path : Example 2


 
========================================================================
[prabhucloudxlab@cxln4 prabhu]$ cat > filegrep.txt
unix is great os. unix is opensource. unix is free os.
learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.


[prabhucloudxlab@cxln4 prabhu]$ cat>search_string.sh
echo "enter the path"
read path

echo "enter the string1 to search in the path"
read str1

search="$(grep -lr $str1 $path )"
echo "the path of the string is : $search" 


[prabhucloudxlab@cxln4 prabhu]$ sh search_string.sh

enter the path
/home/adimulamvenkat19851609/prabhu

enter the string1 to search in the path
hadoop

the path of the string is : /home/adimulamvenkat19851609/prabhu/search.txt