f



sed 's/"""//' foobar | more

Hello I am a total newbie to sed, and I am using sed on DOS, I guess
from some kind of Unix-compatible toolset that is installed:

>C:\tmp>which sed
/usr/bin/sed

Please tell me why is this (foobar is an empty file):

C:\tmp>sed 's/"""//' foobar | more
sed: can't read |: No such file or directory
sed: can't read more: No such file or directory

Normally, DOS | is a special character and is not included on the
command line for commands (such as sed), instead, it is a pipe.  But
here, sed wants to think | is a file.  Now, if I omit one quote,
everything works as expected:

C:\tmp>sed 's/""//' foobar | more

C:\tmp>

Why???  Thank you!  Mark
0
Mark_Galeck
10/20/2009 8:10:15 PM
comp.lang.awk 3450 articles. 0 followers. Post Follow

2 Replies
732 Views

Similar Articles

[PageSpeed] 13

Mark_Galeck wrote:
> Hello I am a total newbie to sed, and I am using sed on DOS, I guess
> from some kind of Unix-compatible toolset that is installed:

Your in the wrong newsgroup.

Check one of newsgroups for DOS, sed, the tool manufacturer.

> 
>> C:\tmp>which sed
> /usr/bin/sed
> 
> Please tell me why is this (foobar is an empty file):
> 
> C:\tmp>sed 's/"""//' foobar | more
> sed: can't read |: No such file or directory
> sed: can't read more: No such file or directory
> 
> Normally, DOS | is a special character and is not included on the

Normally in DOS the double quotes are special, and all kind of fancy
things happen.

> command line for commands (such as sed), instead, it is a pipe.  But
> here, sed wants to think | is a file.  Now, if I omit one quote,
> everything works as expected:

Hard to believe. I would have thought that a "" in a file would not
be removed by that command but what do I know about the DOS sickness.

> 
> C:\tmp>sed 's/""//' foobar | more
> 
> C:\tmp>
> 
> Why???  Thank you!  Mark

Since you've strayed in an awk group, put the following in a_file...

   {sub(/""/,"");print}

and call it as...

   awk -f a_file foobar


Janis
0
Janis
10/20/2009 8:23:41 PM
On Tue, 20 Oct 2009 13:10:15 -0700, Mark_Galeck wrote:

> Hello I am a total newbie to sed, and I am using sed on DOS, I guess from
> some kind of Unix-compatible toolset that is installed:

Most likely Cygwin.  The Cygwin shell is bash - if you launch Cygwin with
it's starup batch file, it will load bash and *ix quoting will work as you
expect.
> 
>>C:\tmp>which sed
> /usr/bin/sed
> 
> Please tell me why is this (foobar is an empty file):
> 
> C:\tmp>sed 's/"""//' foobar | more
> sed: can't read |: No such file or directory sed: can't read more: No
> such file or directory
> 
> Normally, DOS | is a special character and is not included on the
> command line for commands (such as sed), instead, it is a pipe.  But
> here, sed wants to think | is a file.  Now, if I omit one quote,
> everything works as expected:
> 
> C:\tmp>sed 's/""//' foobar | more

I rather doubt it does work as you think it does - if the command
intreperter is CMD.EXE, the quoting is totally wrong: where you have
single quotes, you usually have to use double quotes and escape any
literal doubel quotes inside the outer ones.  Your original problem was
due to the odd number of double quotes (Windows does not recognize \ as
the escape character - it uses ^).

If you want to use Gnu utilities in the Windows environment, I recommend
using the ones found at http://gnuwin32.sourceforge.net/packages.html -
many of the common utilities are in the CoreUtils package.  There are some
functional differences, and Windows quoting conventions have to be
observed, but for the most part, they work reliabily, and are native
Windows32 executables.  Needless to say, I am particularly fond of the
versions of gawk they offer.

-- 

T.E.D. (tdavis@mst.edu)


0
Ted
10/21/2009 12:06:01 AM
Reply: