PDA

View Full Version : Bash: How do I set variables in grep?



bashhelp
November 22nd, 2005, 01:21 AM
for xrm in `ls`; do
if echo $xrm | grep -q *.html; then
rm $xrm
fi; done


The asterisk (*) are not functioning as variables. How do I make grep understand variables?

dabear
November 22nd, 2005, 02:08 AM
try using egrep instead

toojays
November 22nd, 2005, 08:12 AM
The code you have doesn't make sense in the context of either grep or egrep. What exactly are you trying to do?

dabear
November 22nd, 2005, 04:34 PM
I would assume he's trying to delete all files in a directory which contains «.html»