On 13Jul2017 11:33, bruce <badoug...@gmail.com> wrote:
i'm missing something. thoughts/comments?

trying to do a rm with find/exec.

ssh  crawl_user@1.2.3.4 " rm -f '/cloud_nfs/*hash*.dat' ;  find
/cloud_nfs  -name '*austincc*master*book*.dat' -exec rm {} \; rm -f
'/cloud_nfs_fetch/*hash*.dat' ; "

i get
find: paths must precede expression: rm
Usage: find [-H] [-L] [-P] [-Olevel] [-D
help|tree|search|stat|rates|opt|exec] [path...] [expression]

can't seem to see my error...

however, if I remove the last rm -- the find/exec/rm works..

The argument to -exec is a command and arguments; the command is invoked directly from find; the shell is _not_ inolved. You're trying to (half) treat it as a shell command; there's no shell syntax use here because it never goes near the shell.

So you're just asking to invoke "rm {}" and then find is seeing the following "rm" when it is expecting another -blah operator.

Get your command right, interactively, on the remote machine first. Trying to debug this via an:

 ssh ... "blah"

will only make debugging even harder.

What should your remote command be?

It currently looks a bit like:

rm -f '/cloud_nfs/*hash*.dat'
find /cloud_nfs -name '*austincc*master*book*.dat' -exec rm {} \; rm -f 
'/cloud_nfs_fetch/*hash*.dat'

Did you want:

rm -f '/cloud_nfs/*hash*.dat'
find /cloud_nfs -name '*austincc*master*book*.dat' -exec rm {} \;
rm -f '/cloud_nfs_fetch/*hash*.dat'

First up, by putting quotes around your /cloud_nfs paths, you prevent the globs from working - they're trying to remove the literal path '/cloud_nfs/*hash*.dat', not all the files the glob would match. Drop the single quotes.

Note that you _do_ need the quotes in the find command because you are asking find itself to do the match, so the glob string must get to find untouched. Therefore the quotes to _prevent_ the glob being expanded.

Anyway, get your command correct directly on the remote host. Then construct the "ssh crawl..." incantation as a second step.

Also, you may find turning on the -x shell option _very_ useful for debugging remove commands. Thus:

 ssh crawl_user@1.2.3.4 "set -x; shell command here ..."

It will should you the precise commands dispatched at the far end, which goes a long way towards figuring out what you may have got wrong.

Cheers,
Cameron Simpson <c...@zip.com.au>
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org

Reply via email to