I have this line from
'user' => '',
What would be the appropriate command using grep to query the exact line?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Use double quotes to enclose your pattern:
grep "'user' => ''," your_file
I would also make use of some metacharacters to ensure the lookup is robust to the different spacing styles used by people:
grep "'user'\s*=>\s*''\s*," your_file
To add different keywords to your search, you need extended regular expressions. Supply the
-E switch to
grep -E "'(user|group|foo)'\s*=>\s*''\s*," your_file
The above will print lines matching
'user' => '', or
'group' => '', or
'foo' => '', (with different spacing variations). Modify as needed.