[mdlug] Bash back quotes do not work with backslash

R KANNAN rk111810 at gmail.com
Fri Jun 29 16:24:58 EDT 2012


Thanks Michael & Michael. I think $(...) is a good solution.


On Fri, Jun 29, 2012 at 3:21 PM, Michael Corral <micorral at comcast.net>wrote:

> 2012-06-29, Monsieur R KANNAN a ecrit:
> > 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 ^'\$'`
>
> If you use backticks then double-escape the $ sign:
>
> test=`fgrep -i AMLSNCPU WK_sol_103_amls.dat | grep -m 1 -v ^'\\$'`
>
> It's better to use test=$(...) instead, no double-escape required.
>
> Michael
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>



More information about the mdlug mailing list