Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Aug 2006 11:13:21 -0400
From:      Bill Moran <wmoran@collaborativefusion.com>
To:        Ensel Sharon <user@dhp.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: deleting with wildcards over ssh ... how ?
Message-ID:  <20060830111321.037c293e.wmoran@collaborativefusion.com>
In-Reply-To: <Pine.LNX.4.21.0608301059480.31959-100000@shell.dhp.com>
References:  <Pine.LNX.4.21.0608301059480.31959-100000@shell.dhp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In response to Ensel Sharon <user@dhp.com>:

> 
> I want to delete some remote files with a wildcard, running 'rm' over ssh.
> 
> The obvious syntax doesn't work at all - it doesn't even make an ssh
> connection - I think it is interpreting the wildcard locally:
> 
> # ssh user@host rm -rf /some/testdir/*
> ssh: No match.
> 
> Then, these combinations of single and double quotes:
> 
> ssh user@host 'rm -rf /some/testdir/*'
> 
> ssh user@host rm -rf '/some/testdir/*'
> 
> ssh user@host 'rm -rf "/some/testdir/*"'
> 
> All connect over ssh, and produce no errors, but the remote files are
> still there - nothing was deleted.
> 
> So what is the _right_ way to do this ?

Most of those should work.  What are the names of the files you are
trying to delete?  By default, * does not match filenames beginning
with a '.'.  The best command line would be:
ssh user@host 'rm -rf /some/testdir/*'
which will cause the local machine to send the command without expanding
the * first.  The * should then be expanded on the remote system.  Try:
ssh user@host 'echo /some/testdir/*'
to see if it's doing what you expect.

-- 
Bill Moran
Collaborative Fusion Inc.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060830111321.037c293e.wmoran>