0

If I use -E option for grep from a script I'm unable to user variables. For example:

txt file:

word
nir asd b asd
text

script:

#!/bin/bash

PARAM=b
cat txt | grep -E 'nir.*${PARAM}'

The script return nothing. I guess with -E option I need to escape the variable somehow.

  • That is "useless use of cat". – Hauke Laging Jan 31 '16 at 9:49
  • It's just a small example for you to understand the real problem, e.g the grep. The " solved it, thanks – Nir Jan 31 '16 at 9:54
0
PARAM=b
grep -E "nir.*${PARAM}" txt

or

grep -E 'nir.*'"${PARAM}" txt
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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