December 20th, 2013, 02:10 PM
Grep usage issue
I am trying to find files that contain
so I go ahead and I issue
but it flags lines that contain
without the COOKIE part.
grep -R -i $_COOKIE\['teacher_m_name *
December 20th, 2013, 03:46 PM
Quote the whole term otherwise the shell will interpret it.
Because $_COOKIE looks like a variable and so all you pass is just "[teacher_f_name]".
grep -R -i "\$_COOKIE\['teacher_f_name']"
December 20th, 2013, 08:06 PM
I've tried so many different iterations without any success:
and no results. Can someone help with the grep command to find
in a file?
December 20th, 2013, 10:38 PM
I presume you are trying to find whatever value that $_COOKIE variable holds, as opposed to the literal value?
You'd need to wrap the variable reference in quotes, to be sure that if the value has spaces or some special characters in you'll be covered.
If you are only after the files that contain the value then you'll want the -l (ell) flag to return only filenames that have the matching text in. So, assuming you want it to recurse down the directory structure from current directory and be a case-insensitive search then try:
grep -R -i -l "$_COOKIE['teacher_f_name']" *
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
December 21st, 2013, 12:07 AM
What I posted? I tested that exact command. Worked fine for me.
December 21st, 2013, 08:59 PM
Not trying to get anyone upset here. This is the command that worked for me
It drove me NUTS but thanks to you and your suggestions I got it to work.
I need this grep to work because I will be able to see if certain generated cookies are used or not.
Last edited by epanagio; December 21st, 2013 at 09:23 PM.