* Re: Question about "find -exec"
[not found] <Pine.LNX.4.21.0207250114250.2569-100000@hestia.rdrs.net>
@ 2002-07-25 6:05 ` James Mohr
0 siblings, 0 replies; 7+ messages in thread
From: James Mohr @ 2002-07-25 6:05 UTC (permalink / raw)
To: linux-newbie
On Thursday 25 July 2002 01:26, mailing-lists@xs4all.nl wrote:
> Hello,.....
>
> On Wed, 24 Jul 2002, James Mohr wrote:
> > On Wednesday 24 July 2002 09:07, Mike Castle wrote:
> > > In article <200207190752.38161.linux-newbie@jimmo.com>,
> > >
> > > James Mohr <linux-newbie@jimmo.com> wrote:
> > > >You need to tell -exec which file to process. This is done with curly
> > > > braces:
> > > >
> > > >find /mnt/c/ -name *.snm -exec ls {} \;
> > > >
> > > >However, without the -exec, your command will simply list the files
> > > > anyway. I am assuming that this is just an example, and you would
> > > > want to do more than just list the file name. You could exand this
> > > > concept and use the curly
> > >
> > > Also, you should realize that for each file processed, there is the
> > > overhead of fork()/exec() calls.
> > >
> > > You would probably find something like:
> > >
> > > find /mnt/c -name '*.snm' | xargs -r ls -l
>
> Why preform an extra call to `xargs' if you can use the `-printf format'
> or `-ls' option with `find'? e.g
> (find /mnt/c -name -regex ".*\.snm" -ls),
> (find /mnt/c -name -regex ".*\.snm" -printf "%f %b\n")
You wouldn't. At least I wouldn't. As I said in my original answer:
"I am assuming that this is just an example, and you would want to do more
than just list the file name."
I was simply trying to answer the question why the command was not working as
expected and provide additional information on the use of find -exec. Mike
was trying to explain why the find -exec is not always the best solution. I
don't think either of us would use either of these just to list the file
names.
Actually, I often use ls -lR or just ls -R and pipe to grep looking for files.
I don't think either way is intrinsically "better" (at least not in an
absolute sense).
Regards,
jimmo
--
---------------------------------------
"Be more concerned with your character than with your reputation. Your
character is what you really are while your reputation is merely what others
thing you are." -- John Wooden
---------------------------------------
Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info
---------------------------------------
NOTE: All messages sent to me in response to my posts to newsgroups or forums
are subject to reposting.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Question about "find -exec"
@ 2002-07-18 15:28 Petras, Martin [Ontario]
0 siblings, 0 replies; 7+ messages in thread
From: Petras, Martin [Ontario] @ 2002-07-18 15:28 UTC (permalink / raw)
To: Linux Newbie List (E-mail)
try
find /mnt/c -name "*.snm" -ls
or with exec
find /mnt/c -name "*.snm" -exec ls -l {} \;
-----Original Message-----
From: Oliver Ob [mailto:ob_ok@gmx.net]
Sent: Thursday, July 18, 2002 11:24 AM
To: Lx Newbie List
Subject: Question about "find -exec"
I want to find and list all files with *.snm ending.
find /mnt/c/ -name *.snm -exec ls
does not work, the man page does tell me french fries.
What am I missing?
--
*º¤., ¸¸,.¤º*¨¨¨*¤ =Oliver@home= *º¤., ¸¸,.¤º*¨¨*¤
I http://www.bmw-roadster.de/Friends/Olli/olli.html I
I http://www.bmw-roadster.de/Friends/friends.html I
I http://groups.yahoo.com/group/VGAP-93 I
I mailto:VGAP-93-subscribe@yahoogroups.com I
I http://home.t-online.de/home/spacecraft.portal I
>>> Telek0ma iBBMS - now back online +49.4504.TRSi1/TRSi2 <<<
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread* Question about "find -exec"
@ 2002-07-18 15:24 Oliver Ob
2002-07-19 5:52 ` James Mohr
2002-07-19 9:16 ` szonyi calin
0 siblings, 2 replies; 7+ messages in thread
From: Oliver Ob @ 2002-07-18 15:24 UTC (permalink / raw)
To: Lx Newbie List
I want to find and list all files with *.snm ending.
find /mnt/c/ -name *.snm -exec ls
does not work, the man page does tell me french fries.
What am I missing?
--
*º¤., ¸¸,.¤º*¨¨¨*¤ =Oliver@home= *º¤., ¸¸,.¤º*¨¨*¤
I http://www.bmw-roadster.de/Friends/Olli/olli.html I
I http://www.bmw-roadster.de/Friends/friends.html I
I http://groups.yahoo.com/group/VGAP-93 I
I mailto:VGAP-93-subscribe@yahoogroups.com I
I http://home.t-online.de/home/spacecraft.portal I
>>> Telek0ma iBBMS - now back online +49.4504.TRSi1/TRSi2 <<<
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about "find -exec"
2002-07-18 15:24 Oliver Ob
@ 2002-07-19 5:52 ` James Mohr
2002-07-24 7:07 ` Mike Castle
2002-07-19 9:16 ` szonyi calin
1 sibling, 1 reply; 7+ messages in thread
From: James Mohr @ 2002-07-19 5:52 UTC (permalink / raw)
To: Lx Newbie List
On Thursday 18 July 2002 17:24, Oliver Ob wrote:
> I want to find and list all files with *.snm ending.
> find /mnt/c/ -name *.snm -exec ls
> does not work, the man page does tell me french fries.
>
> What am I missing?
You need to tell -exec which file to process. This is done with curly braces:
find /mnt/c/ -name *.snm -exec ls {} \;
However, without the -exec, your command will simply list the files anyway. I
am assuming that this is just an example, and you would want to do more than
just list the file name. You could exand this concept and use the curly
braces anywhere in the command. So, to move the files you find to another
directory you might have this:
find /mnt/c/ -name *.snm -exec mv {} /somewhere/else \;
Note that the \; tells the -exec that you are at the end of the command. For
details on using find with other commands, check this out:
http://www.linux-tutorial.info/cgi-bin/display.pl?32&0&0&0&3
Regards,
jimmo
--
---------------------------------------
"Be more concerned with your character than with your reputation. Your
character is what you really are while your reputation is merely what others
thing you are." -- John Wooden
---------------------------------------
Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info
---------------------------------------
NOTE: All messages sent to me in response to my posts to newsgroups or forums
are subject to reposting.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Question about "find -exec"
2002-07-19 5:52 ` James Mohr
@ 2002-07-24 7:07 ` Mike Castle
2002-07-24 16:07 ` James Mohr
0 siblings, 1 reply; 7+ messages in thread
From: Mike Castle @ 2002-07-24 7:07 UTC (permalink / raw)
To: linux-newbie
In article <200207190752.38161.linux-newbie@jimmo.com>,
James Mohr <linux-newbie@jimmo.com> wrote:
>You need to tell -exec which file to process. This is done with curly braces:
>
>find /mnt/c/ -name *.snm -exec ls {} \;
>
>However, without the -exec, your command will simply list the files anyway. I
>am assuming that this is just an example, and you would want to do more than
>just list the file name. You could exand this concept and use the curly
Also, you should realize that for each file processed, there is the
overhead of fork()/exec() calls.
You would probably find something like:
find /mnt/c -name '*.snm' | xargs -r ls -l
to be significantly faster.
If you expect that there will be any spaces involved, consider using
-print0/-0 in addition:
find /mnt/c -name '*.snm' -print0 | xargs -0 -r ls -l
mrc
--
Mike Castle dalgoda@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Question about "find -exec"
2002-07-24 7:07 ` Mike Castle
@ 2002-07-24 16:07 ` James Mohr
0 siblings, 0 replies; 7+ messages in thread
From: James Mohr @ 2002-07-24 16:07 UTC (permalink / raw)
To: linux-newbie
On Wednesday 24 July 2002 09:07, Mike Castle wrote:
> In article <200207190752.38161.linux-newbie@jimmo.com>,
>
> James Mohr <linux-newbie@jimmo.com> wrote:
> >You need to tell -exec which file to process. This is done with curly
> > braces:
> >
> >find /mnt/c/ -name *.snm -exec ls {} \;
> >
> >However, without the -exec, your command will simply list the files
> > anyway. I am assuming that this is just an example, and you would want to
> > do more than just list the file name. You could exand this concept and
> > use the curly
>
> Also, you should realize that for each file processed, there is the
> overhead of fork()/exec() calls.
>
> You would probably find something like:
>
> find /mnt/c -name '*.snm' | xargs -r ls -l
>
> to be significantly faster.
>
> If you expect that there will be any spaces involved, consider using
> -print0/-0 in addition:
>
> find /mnt/c -name '*.snm' -print0 | xargs -0 -r ls -l
>
> mrc
Valid point. However, I typically don't find it an issue unless you are
running the -exec on 10K files. If it takes 0.1 second with xargs and 1
second with -exec (which is 10 times as long), I don't see it is worth
arguing about.
However, it is **definately** worth mentioning and I have made a note to add
it to my Linux Tutorial.
Regards,
jimmo
--
---------------------------------------
"Be more concerned with your character than with your reputation. Your
character is what you really are while your reputation is merely what others
thing you are." -- John Wooden
---------------------------------------
Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info
---------------------------------------
NOTE: All messages sent to me in response to my posts to newsgroups or forums
are subject to reposting.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Question about "find -exec"
2002-07-18 15:24 Oliver Ob
2002-07-19 5:52 ` James Mohr
@ 2002-07-19 9:16 ` szonyi calin
1 sibling, 0 replies; 7+ messages in thread
From: szonyi calin @ 2002-07-19 9:16 UTC (permalink / raw)
To: Oliver Ob, Lx Newbie List
--- Oliver Ob <ob_ok@gmx.net> a écrit : > I want to
find and list all files with *.snm ending.
> find /mnt/c/ -name *.snm -exec ls
> does not work, the man page does tell me french
> fries.
>
> What am I missing?
>
try
find /mnt/c/ -name *.snm -exec ls \; -print
(No warranty that it will work :-)) )
> --
> *º¤., ¸¸,.¤º*¨¨¨*¤ =Oliver@home=
> *º¤., ¸¸,.¤º*¨¨*¤
> I
> http://www.bmw-roadster.de/Friends/Olli/olli.html
> I
> I
> http://www.bmw-roadster.de/Friends/friends.html
> I
> I http://groups.yahoo.com/group/VGAP-93
> I
> I mailto:VGAP-93-subscribe@yahoogroups.com
> I
> I
> http://home.t-online.de/home/spacecraft.portal
> I
> >>> Telek0ma iBBMS - now back online
> +49.4504.TRSi1/TRSi2 <<<
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at
http://www.linux-learn.org/faqs
=====
--
The UNIX Hierarchy - Beginner
- insecure with the concept of a terminal
- has yet to learn the basics of "vi"
- has not figured out how to get a directory
- still has trouble with typing <RETURN> after each line of input
___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-07-25 6:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.21.0207250114250.2569-100000@hestia.rdrs.net>
2002-07-25 6:05 ` Question about "find -exec" James Mohr
2002-07-18 15:28 Petras, Martin [Ontario]
-- strict thread matches above, loose matches on Subject: below --
2002-07-18 15:24 Oliver Ob
2002-07-19 5:52 ` James Mohr
2002-07-24 7:07 ` Mike Castle
2002-07-24 16:07 ` James Mohr
2002-07-19 9:16 ` szonyi calin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.