Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a variable "abc" with value "xyz*!@#" in my unix account (ksh). I used export command to export this variable into the environment. When I use grep command as below

env |grep xyz

I get the output


But when I use the following command

env | grep xyz*!

As expected I don't get the output as


In fact, I don't get any output at all.

share|improve this question
up vote 3 down vote accepted

* has special meaning in regular expressions, so escape it:

env | grep 'xyz\*!'

Or use the -F option to tell grep to treat the parameter as plain text, not as regular expression:

env | grep -F 'xyz*!'
share|improve this answer
When not using regex, grep -F is probably easier than trying to escape not-a-regex into a regex with normal grep. – jw013 Nov 1 '12 at 13:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.