[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] substitution causing issues in ssh to remote host backti
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] substitution causing issues in ssh to remote host backtick |
Date: |
Fri, 8 Aug 2014 13:26:21 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Fri, Aug 08, 2014 at 08:26:28AM -0700, Rajeev Prasad wrote:
> 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'
The $folder expansion will be done on the server, which presumably does not
have a variable by that name. The client's variable is not passed along
to the server.
The ls|grep -v is also horrible. That is an extremely error-prone way
to try to iterate over a directory and exclude some files.
You may want something like this:
ssh "$host" bash <<EOF
for t in "$folder"/*; do
if [[ \$t = *xxx* ]]; then continue; fi
something with "\$t" and sed that I do not understand
done
EOF