Filtering output from a command

R

RichardOnRails

Hi,

I'd like to do something like:

dir *.rb | find ".rb"

in order to filter out everything returned by Dir except lines that
presumably contain the file-names.

"find" appears not to be a legitimate, but I recall doing something
like this in DOS and/or early versions of Windows like 3.1. I Googled
for this and checked MS' docs for XP's command line to no avail

(There may be an option like that for Dir, but I'm interested in the
filtering process itself, not that particular command.)

Any ideas?

Thanks in advance,
Richard
 
T

Tester

Try this:

dir *.rb /b

The above command will return all files with .rb as extension and
nothing else.

hth
 
B

Bob Willard

Hi,

I'd like to do something like:

dir *.rb | find ".rb"

in order to filter out everything returned by Dir except lines that
presumably contain the file-names.

"find" appears not to be a legitimate, but I recall doing something
like this in DOS and/or early versions of Windows like 3.1. I Googled
for this and checked MS' docs for XP's command line to no avail

(There may be an option like that for Dir, but I'm interested in the
filtering process itself, not that particular command.)

Any ideas?

Thanks in advance,
Richard

Find is still there, at least in the 32bit versions of XP SP3 and
Vista. Bring up cmd.exe and type HELP FIND to get the syntax.
 
R

RichardOnRails

Find is still there, at least in the 32bit versions of XP SP3 and
Vista.  Bring up cmd.exe and type HELP FIND to get the syntax.

Hi Bob,

Thanks for your response.

I'm running WinXP-Pro/SP3 (32-bit). Here's what I got in my Command
Window:

=========================
K:\>help find
find: /?: No such file or directory

K:\>help
[snip]
FIND Searches for a text string in a file or files.
FINDSTR Searches for strings in files.
[snip]

K:\>help FIND
FIND: /?: No such file or directory

K:\>
=========================

How in the world could I have destroyed the Find command on my
system? Or better yet, how can I repair my Command sub-system. I've
still got my original WinXP upgrade to Win2K, but with three Service
Packs laid on top of XP, that original disk is useless IMHO.

Any ideas?

Best wishes,
Richard
 
R

RichardOnRails

Try this:

dir *.rb /b

The above command will return all files with .rb as extension and
nothing else.

hth

Hi Tester,

I was confident that Dir had switches for things like "Just give me
the facts Ma'am without all the fluff". Sure 'nuf, Help Dir revealed
the /B switch for "Bare Format". But your example did show me one new
thing: One need not leave white-space between the basic command and a
switch. So, your example was perfect.

But I still want to get "command-chaining" to work for a batch program
I'm writing. Bob Willard led me to discover that my "Find" command is
somehow broken on my WinXP-Pro/SP3 system, and I'd like to get a
solution to that issue.

Best wishes,
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top