[mdlug] Bash back quotes do not work with backslash

R KANNAN rk111810 at gmail.com
Fri Jun 29 12:49:47 EDT 2012


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?



More information about the mdlug mailing list