Home > other >  Match a Square Bracket in grep Without Regex
Match a Square Bracket in grep Without Regex

Time:08-01

The follow grep command returns ZERO matches:

grep -Filr "$dif_refund[0]->{ $a[" /var/www/html/

However, if I just remove the square bracket, several matching filenames are returned:

grep -Filr "$dif_refund[0]->{ $a" /var/www/html/

How can I make my search work with square brackets without using a regular expression?

CodePudding user response:

Just replace your double-quotes w/ single-quotes. The problem is not the square bracket, the problem is the $a

grep -Filr '$dif_refund[0]->{ $a[' /var/www/html/
  • Related