exec command
PleegWat
pleegwat at telfort.nl
Sat Jan 14 11:42:02 UTC 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/14/2012 12:19 PM, CJ Tres wrote:
> I'm trying to use the find and execute commands to remove *.html
> files in various subdirectories within a single directory but the
> command returns "missing argument to `-exec'
>
> the command I've entered is: find -type f -exec rm -rf" followed by
> the path, followed by: -iname '*.html'
>
> Find alone has found all the files but I'm not understanding what
> is wrong with the syntax "-exec rm -rf"
>
> Can someone see an obvious error?
>
You need to terminate the argument to -exec with a ;, which needs to
be quoted or escaped for the shell, and you need to include an
argument of {} which will be replaced by the name of the file find has
found. You also seem to have confused the argument order to find.
find $path -type f -iname '*.html' -exec rm -rf {} \;
Here you should fill your path for $path.
Specifically when deleting files, you may also use the find action
- -delete, which has the same effect as -exec rm:
find $path -type f -iname '*.html' -delete
This version should be faster when a lot of files need to be deleted.
PleegWat
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJPEWoFAAoJEAM6sLJjDJaMpi4H/A7IC4uecdoerhWwmq6FZ0VX
zlrea0qLzYLmxpbD6m7UACotHjBag9i3JK4hoYzzNgfBFNX02lAq5T6uusqQvlBU
hpKhZ/yyLNKgflM2Q+NGrRCpmSXffLQ2Cw91Yv+SfV3Rr3X+wWU01G1PA1VRJnrf
J+frtMjT24OQLYt8nfvlsH4NVz44T6KUJUnf9iepAT74bAPiWynGocA2YtYK+yfL
qPFpcvgvlkeyC6a783Py6p5dFTg3bT3WlLyKVqQ7grq9ov6zcrNg2IuQpJs3Zw2F
KMMSl2R4bzGOF5HDnF6AMGZGRyUNEZTBds8VboXHLIBvMdQFbV7evWsOYRz2fXs=
=MwuR
-----END PGP SIGNATURE-----
More information about the ubuntu-users
mailing list