grep string containing [] brackets

Hello,

I am trying to grep string with square brackets.

for example I want to grep the below string in log.txt file.

 
This is a test[1]

thanks in advance.

  find . -name "*" | xargs grep '\[*\]' *  

Use this command

---------- Post updated at 11:15 AM ---------- Previous update was at 11:14 AM ----------

or simply u can use in current directory

 grep '\[*\]' * 

Or from root u have to find use / instead of .

  find / -name "*" | xargs grep '\[*\]' *

imho you just have to escape the leading square bracket;

$ grep "test\[1]" log.txt

good luck, and success !

alexandre botao
<< botao {dot} org >>