How to add a variable into a grep command
- by twigg
I'm running the following grep command
var=`grep -n "keyword" /var/www/test/testfile.txt`
This work just as expected but I need to insert the file name dynamically from a loop like so:
var=`grep -n "keyword" /var/www/test/`basename ${hd[$i]}`.txt`
But obviously the use of ` brakes this with a unexpected EOF while looking for matching ``' and unexpected end of file
Any ideas of away around this?