[mdlug] Bash back quotes do not work with backslash

Michael Mol mikemol at gmail.com
Fri Jun 29 12:58:58 EDT 2012


On Fri, Jun 29, 2012 at 12:49 PM, R KANNAN <rk111810 at gmail.com> wrote:
> Bash Gurus,
>
> I am trying to look for a string in a file on lines which don't start with
> a '$' and use that line for further processing in bash.
>
>
> Somehow setting a variable from a command (using back quote) gives
> different results than the command itself.
>
>
>
> [t7689rk at lh070p8x WK]$ fgrep -i AMLSNCPU WK_sol_103_amls.dat | grep -m 1 -v
> ^'\$'
>
> PARAM,AMLSNCPU,4
>
> [t7689rk at lh070p8x WK]$ test=`fgrep -i AMLSNCPU WK_sol_103_amls.dat | grep
> -m 1 -v ^'\$'`
>
> [t7689rk at lh070p8x WK]$ echo $test
>
> $ Use AMLSNCPU=4
>
>
>
> Looks like the escaping of $ within back quotes is not working.
>
>
>
> Any thoughts on how I can make it work?

Try using $( your-commands-here )

-- 
:wq



More information about the mdlug mailing list