Discussione:
find command
(troppo vecchio per rispondere)
Ambarabà Biccì Coccò
2007-03-13 11:15:36 UTC
Permalink
When I redirect the FIND output to another file it adds a 'stupid' header I
don't want; see example:


---------- MRPRODUT.TXT
101,'Wine Coolers 1'
11,'Cooling 1'
12,'Cooling 2'
13,'Cooling 3'

How can I remove it?
--
ABC
foxidrive
2007-03-13 11:41:28 UTC
Permalink
On 13 Mar 2007 11:15:36 GMT, "Ambarabà Biccì Coccò"
Post by Ambarabà Biccì Coccò
When I redirect the FIND output to another file it adds a 'stupid' header I
---------- MRPRODUT.TXT
101,'Wine Coolers 1'
11,'Cooling 1'
12,'Cooling 2'
13,'Cooling 3'
How can I remove it?
find "string" < file.txt
--
Posted via a free Usenet account from http://www.teranews.com
Todd Vargo
2007-03-13 11:41:51 UTC
Permalink
Post by Ambarabà Biccì Coccò
When I redirect the FIND output to another file it adds a 'stupid' header I
---------- MRPRODUT.TXT
101,'Wine Coolers 1'
11,'Cooling 1'
12,'Cooling 2'
13,'Cooling 3'
How can I remove it?
FIND "Cool" < file1 > MRPRODUT.TXT
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
--
Posted via a free Usenet account from http://www.teranews.com
Ammammata
2007-03-13 12:44:29 UTC
Permalink
Post by Todd Vargo
Post by Ambarabà Biccì Coccò
How can I remove it?
FIND "Cool" < file1 > MRPRODUT.TXT
ottimo, grazie a entrambi
--
/-\ /\/\ /\/\ /-\ /\/\ /\/\ /-\ T /-\
John Savage
2007-03-18 01:06:47 UTC
Permalink
Post by Ambarabà Biccì Coccò
When I redirect the FIND output to another file it adds a 'stupid' header I
---------- MRPRODUT.TXT
101,'Wine Coolers 1'
11,'Cooling 1'
12,'Cooling 2'
13,'Cooling 3'
How can I remove it?
Easiest way is to not generate it in the first place. Instead of:

find "Cool" filein >fileout, use

find "Cool" <filein >fileout
--
John Savage (my news address is not valid for email)
Marshall Price
2007-03-24 23:13:50 UTC
Permalink
Post by John Savage
Post by Ambarabà Biccì Coccò
When I redirect the FIND output to another file it adds a 'stupid' header I
---------- MRPRODUT.TXT
101,'Wine Coolers 1'
11,'Cooling 1'
12,'Cooling 2'
13,'Cooling 3'
How can I remove it?
find "Cool" filein >fileout, use
find "Cool" <filein >fileout
Spooky!

By the way, I'm usually looking for a word in a file somewhere in a
directory, so I enter:

for %f in (*.txt) do find /i "earthlink" %f >> el.fnd

Could I do that with the "less-than" somehow?

But what I really don't understand is how FOR can sometimes interpret
what's in the parentheses as filespecs and sometimes as other things,
such as strings or commands. Is there something tricky there, or is it
perfectly sensible? (The syntax help only confuses me.)
--
Marshall Price of Miami
Known to Yahoo as d021317c
John Savage
2007-03-25 23:04:28 UTC
Permalink
Post by Marshall Price
By the way, I'm usually looking for a word in a file somewhere in a
for %f in (*.txt) do find /i "earthlink" %f >> el.fnd
Could I do that with the "less-than" somehow?
In standard MSDOS (pre-windoze MSDOS), you need to do it in 2 steps, e.g.,

Step 1: create a one-line file, say MYFIND.BAT, containing just:
@find /i "earthlink" < %1 >> el.fnd

Step 2: run the command:
for %i in (*.txt) do call myfind %i
Post by Marshall Price
But what I really don't understand is how FOR can sometimes interpret
what's in the parentheses as filespecs and sometimes as other things,
such as strings or commands. Is there something tricky there, or is it
perfectly sensible? (The syntax help only confuses me.)
That sounds like NT stuff; you'll need to ask on a windows group for
help with that.
--
John Savage (my news address is not valid for email)
Todd Vargo
2007-03-26 03:24:50 UTC
Permalink
Post by John Savage
Post by Marshall Price
But what I really don't understand is how FOR can sometimes interpret
what's in the parentheses as filespecs and sometimes as other things,
such as strings or commands. Is there something tricky there, or is it
perfectly sensible? (The syntax help only confuses me.)
That sounds like NT stuff; you'll need to ask on a windows group for
help with that.
I don't see why it sounds like NT stuff. The following are perfectly legal
FOR commands in MSDOS/Win9x/Me systems.

::1 Wildcards return existing files.
FOR %? in (*.txt) DO ECHO %?

::2 Strings contain no wildcards.
FOR %? in (filename.exe foo bar 1 2 3) DO echo %?
::%? contains the strings regaurdless of if it exists

::3 Commands are same #2 (except position of %? is moved).
FOR %? in (SHIFT ECHO CALL DEL GOTO:LABEL) DO %? filename.bat

::4 Combinations
FOR %? in (fo?.bat del:foo.bat) DO call %?

Although, OP may well have been refering to /F or "tokens=" or "delims" or
%~f? as being confusing, which as you indicate, are not related to alt.msdos
or it.comp.os.dos.
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
--
Posted via a free Usenet account from http://www.teranews.com
Marshall Price
2007-03-26 10:46:54 UTC
Permalink
Post by Todd Vargo
Post by John Savage
Post by Marshall Price
But what I really don't understand is how FOR can sometimes interpret
what's in the parentheses as filespecs and sometimes as other things,
such as strings or commands. Is there something tricky there, or is it
perfectly sensible? (The syntax help only confuses me.)
That sounds like NT stuff; you'll need to ask on a windows group for
help with that.
I don't see why it sounds like NT stuff. The following are perfectly legal
FOR commands in MSDOS/Win9x/Me systems.
::1 Wildcards return existing files.
FOR %? in (*.txt) DO ECHO %?
::2 Strings contain no wildcards.
FOR %? in (filename.exe foo bar 1 2 3) DO echo %?
::%? contains the strings regaurdless of if it exists
::3 Commands are same #2 (except position of %? is moved).
FOR %? in (SHIFT ECHO CALL DEL GOTO:LABEL) DO %? filename.bat
::4 Combinations
FOR %? in (fo?.bat del:foo.bat) DO call %?
You're right; I'm not talking about NT stuff. But I'm still terribly
confused, as you shall see! :-)

Is it a general rule that any item within the parentheses that contains
a wildcard refers to files in the current directory, while anything that
doesn't is a string, though it can be used to identify a file or command
in the DO part?

First, I take it that the question mark in "%?" behaves just like a
letter of the alphabet. That is, it's not a wildcard, right?

In example 3, the SHIFT boggles my mind! I thought it was only used
within .BAT files and took no arguments.

So what happens is:

SHIFT filename.bat
ECHO filename.bat
CALL filename.bat
DEL filename.bat
GOTO:LABEL filename.bat

Does the GOTO escape from the FOR loop? How does that work? Does it
run filename.bat with an immediate jump to LABEL somehow, and fail
gracefully if LABEL isn't in filename.bat?

Isn't filename.bat already deleted?!

Example 4 basically does this, assuming FOA.BAT, FOB.BAT and FOC.BAT exist:

CALL FOA.BAT
DEL FOO.BAT
CALL FOB.BAT
DEL FOO.BAT
CALL FOC.BAT
DEL FOO.BAT

Right? (The colon in "del:foo.bat" is new to me. I don't understand it.)

Is there an attempted CALL of FOO.BAT, even though it's gone?

Or should it be:

CALL FOA.BAT DEL:FOO.BAT
CALL FOB.BAT DEL:FOO.BAT
CALL FOC.BAT DEL:FOO.BAT

Or:

CALL FOA.BAT
CALL FOB.BAT
CALL FOC.BAT
CALL DEL:FOO.BAT
--
Marshall Price of Miami
Known to Yahoo as d021317c
Todd Vargo
2007-03-26 13:23:19 UTC
Permalink
Post by Marshall Price
Post by Todd Vargo
Post by John Savage
Post by Marshall Price
But what I really don't understand is how FOR can sometimes interpret
what's in the parentheses as filespecs and sometimes as other things,
such as strings or commands. Is there something tricky there, or is it
perfectly sensible? (The syntax help only confuses me.)
That sounds like NT stuff; you'll need to ask on a windows group for
help with that.
I don't see why it sounds like NT stuff. The following are perfectly legal
FOR commands in MSDOS/Win9x/Me systems.
::1 Wildcards return existing files.
FOR %? in (*.txt) DO ECHO %?
::2 Strings contain no wildcards.
FOR %? in (filename.exe foo bar 1 2 3) DO echo %?
::%? contains the strings regaurdless of if it exists
::3 Commands are same #2 (except position of %? is moved).
FOR %? in (SHIFT ECHO CALL DEL GOTO:LABEL) DO %? filename.bat
::4 Combinations
FOR %? in (fo?.bat del:foo.bat) DO call %?
You're right; I'm not talking about NT stuff. But I'm still terribly
confused, as you shall see! :-)
Shall I take your :-) above as meaning the remainder is trolling? Hmmm...
Post by Marshall Price
Is it a general rule that any item within the parentheses that contains
a wildcard refers to files in the current directory, while anything that
doesn't is a string, though it can be used to identify a file or command
in the DO part?
In general, yes, except "current directory" only applies if you have not
specified a directory.

CD c:\windows
FOR %? in (c:\abc\123\*.txt) do echo %?

Clearly, above does not refer to "current directory".
Post by Marshall Price
First, I take it that the question mark in "%?" behaves just like a
letter of the alphabet. That is, it's not a wildcard, right?
This is your second question so it can not be "First".
Second, you have taken it correctly.
Post by Marshall Price
In example 3, the SHIFT boggles my mind! I thought it was only used
within .BAT files and took no arguments.
SHIFT filename.bat
ECHO filename.bat
CALL filename.bat
DEL filename.bat
GOTO:LABEL filename.bat
Does the GOTO escape from the FOR loop? How does that work? Does it
run filename.bat with an immediate jump to LABEL somehow, and fail
gracefully if LABEL isn't in filename.bat?
Isn't filename.bat already deleted?!
Well, since SHIFT AND GOTO only apply to batch files, the %? should be %%?,
but the point in this example was that you can place a list of commands in
the parenthesis, not that they must be used in this exact order or exactly
like this. As for SHIFT and GOTO not taking arguments, you are correct,
however, by simply trying yourself before asking, you would have found the
argument is ignored for these commands and does not cause a batch halting
error.
Post by Marshall Price
CALL FOA.BAT
DEL FOO.BAT
CALL FOB.BAT
DEL FOO.BAT
CALL FOC.BAT
DEL FOO.BAT
Right? (The colon in "del:foo.bat" is new to me. I don't understand it.)
Well, assuming you are writing a batch file that does something productive,
it is up to the author to assure there would not be a FOA, FOB or FOC to
interfere with operation.
Post by Marshall Price
Is there an attempted CALL of FOO.BAT, even though it's gone?
You are reading the examples as being intended for a specific purpose based
on incorrect assumptions.
Post by Marshall Price
CALL FOA.BAT DEL:FOO.BAT
CALL FOB.BAT DEL:FOO.BAT
CALL FOC.BAT DEL:FOO.BAT
CALL FOA.BAT
CALL FOB.BAT
CALL FOC.BAT
CALL DEL:FOO.BAT
As I indicated above, if the batch author wrote code to assure FOA, FOB and
FOC would not exist, then all it would do is CALL and DEL FOO.BAT as the
author intended.

For example...

@echo off
for %%? in (md cd) do %%? mytmp
echo do something useful>foo.bat
for %%? in (call del) do %%? foo.bat
for %%? in (cd.. rd:mytmp) do %%?

That said, my post was not intended to be a one stop newcomer instruction
manual, rather a demonstration that it does require NT to perform these
actions as my "I don't see why it sounds like NT stuff" lead-in indicated.
Sorry if anyone read more into the examples than was intended. Think outside
the box!
--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)
--
Posted via a free Usenet account from http://www.teranews.com
Richard Bonner
2007-03-18 13:02:33 UTC
Permalink
Post by Ambarabà Biccì Coccò
When I redirect the FIND output to another file it adds a 'stupid' header I
How can I remove it?
--
ABC
*** Try using the "/V" switch. Type "FIND /?" for information.

Richard
Loading...