PDA

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


bashhelp
November 21st, 2005, 08:21 PM
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 21st, 2005, 09:08 PM
try using egrep instead

toojays
November 22nd, 2005, 03: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, 11:34 AM
I would assume he's trying to delete all files in a directory which contains «.html»