Reading space from a empty file

Dell / Optiplex gx270...
October 20, 2009 at 06:05:15
Specs: Windows XP, 2.992 GHz / 1021 MB
I have an file which may be empy , I try to read the file and when the file is empty it says "Echo is off" . Y does this happen ? and can we get a space or null out of this so that it would be easy fr me to compare'

See More: Reading space from a empty file

Report •


#1
October 20, 2009 at 06:39:02
Hi.

> I have an file which may be empy , I try to read the file

How do you read it?

> and when the file is empty it says "Echo is off" .

It's not the empty file that says that. It's the echo command.

> Y does this happen ?

I presume that you read each line of the file (or maybe just the first line) into a variable, and then you echo it like this:

echo %line%

If line is not defined (or if it is defined to be one or more spaces or tabs) then the above command is seen as just this:

echo

And the echo command on its own just tells you whether you have echo set to on or off. To fix this, use:

if defined line echo.%line%

So, if line is undefined, nothing happens. If line is just spaces/tabs, it prints a blank line. If it contains printable characters, it prints them. The dot (.) after echo is treated as a delimiter and not printed.

> and can we get a space or null out of this so that it would be easy fr me to compare'

Sorry, can you rephrase. Space or null out of what? Compare with what?


Report •
Related Solutions


Ask Question