![]() |
UNIX Find on Windows
I'm fairly new to using Perl on Windows. I need to find all of the
files in a folder and its sub folders that match a pattern. On UNIX I'd do: $FOUND = `find $DIRROOT -name "$PATTERN" -print`; Is there a way to do this on Windows using Perl and/or native Windows commands? Brian |
Re: UNIX Find on Windows
Brian <brian.getridofthis.bygland@boeingDELETEthis.com > writes:
> I'm fairly new to using Perl on Windows. I need to find all of the > files in a folder and its sub folders that match a pattern. On UNIX I'd > do: > > $FOUND = `find $DIRROOT -name "$PATTERN" -print`; > > Is there a way to do this on Windows using Perl and/or native Windows > commands? perldoc File::Find also, see find2perl (in the standard distribution on Unix; I'd assume also on Windows), which converts find commands into equivalent (but not necessarily optimal) Perl programs that use File::Find. -=Eric -- Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare. -- Blair Houghton. |
Re: UNIX Find on Windows
Eric Schwartz <emschwar@pobox.com> wrote:
> Brian <brian.getridofthis.bygland@boeingDELETEthis.com > writes: >> I need to find all of the >> files in a folder and its sub folders that match a pattern. >> Is there a way to do this on Windows using Perl > perldoc File::Find > > also, see find2perl See also also: http://www.perl.com/language/ppt/src/find/ -- Tad McClellan SGML consulting tadmc@augustmail.com Perl programming Fort Worth, Texas |
Re: UNIX Find on Windows
Brian wrote:
> I'm fairly new to using Perl on Windows. I need to find all of the > files in a folder and its sub folders that match a pattern. On UNIX I'd > do: > > $FOUND = `find $DIRROOT -name "$PATTERN" -print`; > > Is there a way to do this on Windows using Perl and/or native Windows > commands? > > Brian If you must backtic $FOUND = `dir /b /s c:\\dir\\*.txt`; /b give just the file name /s search sub dirs However, depending on how much of a pattern $PATTERN is, you might want to use File::Find as others have suggested. Len |
Re: UNIX Find on Windows
On Tue, 10 Feb 2004 16:51:30 -0700, Eric Schwartz <emschwar@pobox.com>
wrote: >also, see find2perl (in the standard distribution on Unix; I'd assume >also on Windows), which converts find commands into equivalent (but Yes, it's there! Michele -- you'll see that it shouldn't be so. AND, the writting as usuall is fantastic incompetent. To illustrate, i quote: - Xah Lee trolling on clpmisc, "perl bug File::Basename and Perl's nature" |
Re: UNIX Find on Windows
On Tue, 10 Feb 2004 23:13:36 GMT, Brian
<brian.getridofthis.bygland@boeingDELETEthis.com > wrote: >$FOUND = `find $DIRROOT -name "$PATTERN" -print`; BTW, it may be an idiosincrasy of mine, but I'd rather open() a find cmd in pipe and read 'while <$fh>' as usual... >Is there a way to do this on Windows using Perl and/or native Windows >commands? Using Perl: File::Find. Using native Windows commands: dir /b [/s] (but may not do exactlty what you mean!). Alternatively I, for one, have a straight find port from UNXUTILS. But AFAICT I've never used a statement like the one above, the rationale being *IMHO* that if the task is simple enough to fit nicely in a series of piped commands on the cmd line, then find is the right tool for this, and Perl may not even be necessary whereas if the task is complex enough to deserve the full power of Perl, then I'd use File::Find instead. Michele -- you'll see that it shouldn't be so. AND, the writting as usuall is fantastic incompetent. To illustrate, i quote: - Xah Lee trolling on clpmisc, "perl bug File::Basename and Perl's nature" |
Re: UNIX Find on Windows
Thank you Eric.
Eric Schwartz wrote: > > Brian <brian.getridofthis.bygland@boeingDELETEthis.com > writes: > > I'm fairly new to using Perl on Windows. I need to find all of the > > files in a folder and its sub folders that match a pattern. On UNIX I'd > > do: > > > > $FOUND = `find $DIRROOT -name "$PATTERN" -print`; > > > > Is there a way to do this on Windows using Perl and/or native Windows > > commands? > > perldoc File::Find > > also, see find2perl (in the standard distribution on Unix; I'd assume > also on Windows), which converts find commands into equivalent (but > not necessarily optimal) Perl programs that use File::Find. > > -=Eric > -- > Come to think of it, there are already a million monkeys on a million > typewriters, and Usenet is NOTHING like Shakespeare. > -- Blair Houghton. |
Re: UNIX Find on Windows
Thanks. I'll look at File::Find. This is a part of a fairly complex
script that I'm porting from UNIX to Windows. I'm trying to remove all of the backtick/system commands that I can to make to portable. Michele Dondi wrote: > > On Tue, 10 Feb 2004 23:13:36 GMT, Brian > <brian.getridofthis.bygland@boeingDELETEthis.com > wrote: > > >$FOUND = `find $DIRROOT -name "$PATTERN" -print`; > > BTW, it may be an idiosincrasy of mine, but I'd rather open() a find > cmd in pipe and read 'while <$fh>' as usual... > > >Is there a way to do this on Windows using Perl and/or native Windows > >commands? > > Using Perl: File::Find. Using native Windows commands: dir /b [/s] > (but may not do exactlty what you mean!). Alternatively I, for one, > have a straight find port from UNXUTILS. > > But AFAICT I've never used a statement like the one above, the > rationale being *IMHO* that if the task is simple enough to fit nicely > in a series of piped commands on the cmd line, then find is the right > tool for this, and Perl may not even be necessary whereas if the task > is complex enough to deserve the full power of Perl, then I'd use > File::Find instead. > > Michele > -- > you'll see that it shouldn't be so. AND, the writting as usuall is > fantastic incompetent. To illustrate, i quote: > - Xah Lee trolling on clpmisc, > "perl bug File::Basename and Perl's nature" |
Re: UNIX Find on Windows
I.E. wrote:
> On Tue, 10 Feb 2004 23:13:36 GMT, Brian > <brian.getridofthis.bygland@boeingDELETEthis.com > wrote: > >> I'm fairly new to using Perl on Windows. I need to find all of the >> files in a folder and its sub folders that match a pattern. On UNIX >> I'd do: >> >> $FOUND = `find $DIRROOT -name "$PATTERN" -print`; >> >> Is there a way to do this on Windows using Perl and/or native Windows >> commands? >> >> Brian > > Have you given Cygwin a try? www.cygwin.com Find seems to work well in cygwin, but be aware some commands are actually wrappers of the built-in Windows equivelent. Such as netstat. This may be going a little off scope, I just mean it a warning to anyone who mistakenly has the impression that everything in it is pure Unix. There was a discussion on this a while ago in one of the Unix groups. -- Trent Curry perl -e '($s=qq/e29716770256864702379602c6275605/)=~s!([0-9a-f]{2})!pack("h2",$1 )!eg;print(reverse("$s")."\n");' |
Re: UNIX Find on Windows
Brian <brian.getridofthis.bygland@boeingDELETEthis.com > wrote in message news:<402965A0.ECC43D08@boeingDELETEthis.com>...
> I'm fairly new to using Perl on Windows. I need to find all of the > files in a folder and its sub folders that match a pattern. On UNIX I'd > do: > > $FOUND = `find $DIRROOT -name "$PATTERN" -print`; > > Is there a way to do this on Windows using Perl and/or native Windows > commands? > > Brian Hi Brian, If you want to find all of the files in a folder and its sub folders that match a pattern on Windows using Perl and/or native Windows commands I cannot help. I just do not have enough experience with Perl yet. If the task is just to find all of the files in a folder and its sub folders that match a pattern no matter what kind of tool you will use, I would suggest egrep. egrep for Windows is a part of "GNU utilities for Win32". You can download it from here: http://unxutils.sourceforge.net/ You can use something like this: egrep -lr PATTERN *.* for example: egrep -lr "^From|Subject|Date: " *.* |
| All times are GMT. The time now is 06:12 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.