Re: [Help-bash] substitution causing issues in ssh to remote host backti
From:
Chet Ramey
Subject:
Re: [Help-bash] substitution causing issues in ssh to remote host backtick
Date:
Fri, 08 Aug 2014 13:23:55 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
On 8/8/14, 11:26 AM, Rajeev Prasad wrote:
> hello friends,
>
> can someone help understand why 1st is working but second is not?
>
> working:
> ssh server10 'for t in `ls /xyz/abc/lmn|grep -v xxx`;do ls /xyz/abc/lmn/$t |
> sed -e "s/some/someelse/";done'
>
> not working:
> host=server10
> folder=/xyz/abc/lmn
> ssh $host 'for t in `ls $folder|grep -v xxx`;do ls $folder/$t | sed -e
> "s/some/someelse/";done'
>
> it seems substitution inside backtick is causing the failure, but i am not
> able to understand why?
The single quotes inhibit variable expansion in the context where you want
it to take place.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/