Hi
Let say there is a file a.txt which contain number rows.
My intention is to find the number of occurences of a pattern. Let say the pattern is mdbase. then it should not count the occurences of mdbase1 or mdbase2 like this. When I tried to find it like
grep "/backup/surjya/mdbase" xmldir.conf_backup | wc -w
The out put is 3 rather than 1. So please let me know how it can be resolved
I tried like below:
dir2=\"$dir1"\>"\"
echo $dir2
stgdircount=`grep $dir2 xmldir.conf | wc -w | awk '{print $1}'`
echo $stgdircount
let say dir1=/backup/surjya/mdbase. hence the output for dir2 is
"/backup/surjya/mdbase\>"
and for stgdircount is 0, but exactly there is two entries in this file. Please give me some idea.
yes you are right but why it gives 0 when I try to execute it through shell script. Let say the script is
dir1=/backup/surjya/mdbase
stgcnt=`grep -c $dir1 surya.txt `
echo $stgcnt
The value of stgcnt is 5.
Just modify the script like
dir1=/backup/surjya/mdbase
stgcnt=`grep -c \"$dir1"\>"\" surya.txt `
echo $stgcnt
The value of stgcnt is 0
I hope my question is clear.