Search code examples
bashcygwin

bash export expression without expanding?


I want to do the following

export LOGS=//server/log_files/2014_*/server_{1,2,3}

so I can do something like

grep 'Exception' $LOGS/log.txt

I tried alias as well, but I can't get it to not expand.

How could I do this?


Solution

  • Without export, right hand side of an assignment doesn't go through path nor brace expansion.

    With export, though, brace expansion is performed. You can prevent it by quoting the value:

    export LOGS='//server/log_files/2014_*/server_{1,2,3}'
    

    If you want to use such a value, though, you have to use eval:

    eval grep 'Exception' $LOGS/log.txt