Hi everyone,
I am trying to search for a string in a file that is partly made up of a variable. Here's the code:
echo "parentCategory = $parentCategory"
echo "parentCategoryFormatted = $parentCategoryFormatted"
numUrlsFoundInParentCategory=`grep -c "<Topic r:id=\"Top\/World\/Fran�ais\/" $inputFile`
echo "Hard-coded result = $numUrlsFoundInParentCategory"
numUrlsFoundInParentCategory=`grep -c \""<Topic r:id=\\\"$parentCategoryFormatted"\" $inputFile`
echo grep -c \""<Topic r:id=\\\"$parentCategoryFormatted"\" $inputFile
echo "Dynamic result = $numUrlsFoundInParentCategory"
It produces the output...
parentCategory = Top/World/Fran�ais/
parentCategoryFormatted = Top\/World\/Fran�ais\/
Hard-coded result = 22093
./dmozStats.sh: command substitution: line 44: unexpected EOF while looking for matching `"'
./dmozStats.sh: command substitution: line 45: syntax error: unexpected end of file
grep -c "<Topic r:id=\"Top\/World\/Fran�ais\/" content.rdf.u8.clean
Dynamic result =
I can't find out why the command using the variable won't work when it appears to look the same as the hard-coded version.
Thanks!