exec command
On 01/14/2012 05:30 AM, Colin Law wrote:
On 14 January 2012 11:19, CJ Tres<ctres@grics.net> 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? man find shows an example similar to your requirement find . -type f -exec file '{}' ; which suggests that you have got some bits missing from the exec spec. Colin Thanks Colin, this helps. Don't know if it's true but years ago I read somewhere that man pages are written by developers for developers. I started reading man find, trying to locate what was relevant to my application and was quickly overwhelmed - never-mind 1500 + lines. Makes me feel deficient when I see "read the man page" everywhere as if it should make everything clear and I often end up more confused after reading them. Maybe if I dug into shell scripting it would help. I feel as if I was trying to understand all aspects of how an automatic transmission operates so I can drive a car... still I continue to slog through them when I have the time. -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On 01/14/2012 05:42 AM, PleegWat wrote:
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. Yes, thanks, much simpler. I've run it on a single folder in a sub directory as a test. It eliminated the majority of the files but another issue has cropped up. All the files are of the "HTML document (text/html)" type, but not all have html or .html in the file name. In fact there is nothing else common to all files - within their names -that need to be deleted and there is a single plain text document in each folder that needs to be excluded from the -delete command. I'm guessing the answer to this in in man find or some other man page? -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On Sat, Jan 14, 2012 at 1:19 PM, CJ Tres <ctres@grics.net> 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? From a book I have been reading: Type this command to find all files in your present working directory whose names are core and then delete them (i.e., automatically run the rm command): $ find . -name core -exec rm {} ; TIP The syntax for the -exec option with the find command as used here can be hard to remember sometimes, and so you can also use the xargs method instead of the exec option used in this example. Using xargs, the command would then be written $ find . -name 'core' | xargs rm I think the xargs method is easier. -- Ioannis Vranos http://cppsoftware.binhoster.com -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On Sat, Jan 14, 2012 at 3:06 PM, CJ Tres <ctres@grics.net> wrote:
> > Thanks Colin, this helps. > > Don't know if it's true but years ago I read somewhere that man pages are > written by developers for developers. > I started reading man find, trying to locate what was relevant to my > application and was quickly overwhelmed - never-mind 1500 + lines. > > Makes me feel deficient when I see "read the man page" everywhere as if it > should make everything clear and I often end up more confused after reading > them. > Maybe if I dug into shell scripting it would help. > > I feel as if I was trying to understand all aspects of how an automatic > transmission operates so I can drive a car... still I continue to slog > through them when I have the time. The man/info pages cover all the arguments functionality of an installed executable file. You use only the arguments you need to. If you want "only to drive the car", as all do, you can just use a graphical environment like GNOME, KDE, XFCE, etc.. You don't have to search for files via command line "find". -- Ioannis Vranos http://cppsoftware.binhoster.com -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On Sat, Jan 14, 2012 at 3:28 PM, CJ Tres <ctres@grics.net> wrote:
> On 01/14/2012 05:42 AM, PleegWat wrote: > >> 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. > > > Yes, thanks, much simpler. > I've run it on a single folder in a sub directory as a test. > It eliminated the majority of the files but another issue has cropped up. > All the files are of the "HTML document (text/html)" type, but not all have > html or .html in the file name. In fact there is nothing else common to all > files - within their names -that need to be deleted and there is a single > plain text document in each folder that needs to be excluded from the > -delete command. > I'm guessing the answer to this in in man find or some other man page? Assuming you want the easy way, in Ubuntu 11.10 desktop, you can use the "Search for files" program. -- Ioannis Vranos http://cppsoftware.binhoster.com -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On 01/14/2012 07:40 AM, Ioannis Vranos wrote:
On Sat, Jan 14, 2012 at 3:06 PM, CJ Tres<ctres@grics.net> wrote: Thanks Colin, this helps. Don't know if it's true but years ago I read somewhere that man pages are written by developers for developers. I started reading man find, trying to locate what was relevant to my application and was quickly overwhelmed - never-mind 1500 + lines. Makes me feel deficient when I see "read the man page" everywhere as if it should make everything clear and I often end up more confused after reading them. Maybe if I dug into shell scripting it would help. I feel as if I was trying to understand all aspects of how an automatic transmission operates so I can drive a car... still I continue to slog through them when I have the time. The man/info pages cover all the arguments functionality of an installed executable file. You use only the arguments you need to. If you want "only to drive the car", as all do, you can just use a graphical environment like GNOME, KDE, XFCE, etc.. You don't have to search for files via command line "find". Yes, most often I just want to get a job done but I also like to get "under the hood" too. -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On 01/14/2012 07:42 AM, Ioannis Vranos wrote:
Assuming you want the easy way, in Ubuntu 11.10 desktop, you can use the "Search for files" program. This also misses some of the files of the type html/text. -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On Sat, Jan 14, 2012 at 4:05 PM, CJ Tres <ctres@grics.net> wrote:
> On 01/14/2012 07:40 AM, Ioannis Vranos wrote: >> >> On Sat, Jan 14, 2012 at 3:06 PM, CJ Tres<ctres@grics.net> *wrote: >>> >>> I feel as if I was trying to understand all aspects of how an automatic >>> transmission operates so I can drive a car... still I continue to slog >>> through them when I have the time. >> >> >> The man/info pages cover all the arguments functionality of an >> installed executable file. You use only the arguments you need to. If >> you want "only to drive the car", as all do, you can just use a >> graphical environment like GNOME, KDE, XFCE, etc.. >> >> You don't have to search for files via command line "find". >> >> > > Yes, most often I just want to get a job done but I also like to get "under > the hood" too. Then what are you complaining about? :-) -- Ioannis Vranos http://cppsoftware.binhoster.com -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On Sat, Jan 14, 2012 at 4:09 PM, CJ Tres <ctres@grics.net> wrote:
> On 01/14/2012 07:42 AM, Ioannis Vranos wrote: > > >> Assuming you want the easy way, in Ubuntu 11.10 desktop, you can use >> the "Search for files" program. > > > > This also misses some of the files of the type html/text. You can search for the string <html inside files. It is the option "Contains the text", in this program. -- Ioannis Vranos http://cppsoftware.binhoster.com -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
exec command
On 01/14/2012 08:58 AM, Ioannis Vranos wrote:
On Sat, Jan 14, 2012 at 4:05 PM, CJ Tres<ctres@grics.net> wrote: On 01/14/2012 07:40 AM, Ioannis Vranos wrote: On Sat, Jan 14, 2012 at 3:06 PM, CJ Tres<ctres@grics.net> wrote: I feel as if I was trying to understand all aspects of how an automatic transmission operates so I can drive a car... still I continue to slog through them when I have the time. The man/info pages cover all the arguments functionality of an installed executable file. You use only the arguments you need to. If you want "only to drive the car", as all do, you can just use a graphical environment like GNOME, KDE, XFCE, etc.. You don't have to search for files via command line "find". Yes, most often I just want to get a job done but I also like to get "under the hood" too. Then what are you complaining about? :-) LOL - point taken! -- ubuntu-users mailing list ubuntu-users@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users |
| All times are GMT. The time now is 04:50 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.