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.

2
  • That is "useless use of cat". Commented Jan 31, 2016 at 9:49
  • It's just a small example for you to understand the real problem, e.g the grep. The " solved it, thanks Commented Jan 31, 2016 at 9:54

1 Answer 1

0
PARAM=b
grep -E "nir.*${PARAM}" txt

or

grep -E 'nir.*'"${PARAM}" txt

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.