2

I'm using the following conditional in a bash script:

if `grep -q "${ACTION_LABEL} Action" "${OVERRIDE_ACTIONS}"`; then .... fi 

It basically works. Except if any part of the path in ${OVERRIDE_ACTIONS} contains a space, then the grep fails. How can I get this to work with paths containing spaces>

1 Answer 1

8

Remove the backticks:

if grep -q "${ACTION_LABEL} Action" "${OVERRIDE_ACTIONS}"; then ... fi 

Why? grep will return a value of 0 if it succeeded in finding occurences for your pattern, or 1 if it failed. The body of the if statement will be executed, if the condition evaluates to 0.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.