I am using gedit text editor with embedded terminal in ubuntu 12.04. I'm trying to search for some text using grep
. I want to search for this line of code
'type' => 'select'
I tried:
grep -r '\'type\' => \'select\''
But grep
didn't return any results.
So can someone kindly tell me how to search for the code above?
Surround your search string with double quotes:
You cannot escape single quotes that appear within single quotes. As explained in the bash manual:
So, you have to use different approaches:
Use double quotes:
If you prefer needlessly complex solutions:
You can always search for any single character instead of specifying the single quotes:
But just use
"
, it makes things much more straightforward.cd to the directory that contains your .txt file
Then :
you can use
grep "'type' => 'select'" name.txt
or :
Output :