Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <41B19CA6.6090203@schoenhaber.de> Date: Sat, 04 Dec 2004 12:16:54 +0100 From: =?ISO-8859-1?Q?Markus_Sch=F6nhaber?= Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041202) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: sed: altered results in bash and cmd References: <1102155735 DOT 2524 DOT 6 DOT camel AT 82-40-123-11 DOT cable DOT ubr01 DOT pert DOT blueyonder DOT co DOT uk> In-Reply-To: <1102155735.2524.6.camel@82-40-123-11.cable.ubr01.pert.blueyonder.co.uk> X-Enigmail-Version: 0.89.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes fergus wrote: > To delete all lines beginning with a in a text file, this > command (a) seems correctly composed and (b) works: > > sed '/^ .*$/d' filename > > but if I use it in a cmd window, the result is that all lines > _containing_ a space are deleted, not just those beginning with a space. > > In general, and assuming PATHs etc correctly set, should not Cygwin > command lines work identically in bash and cmd windows? Is this a > problem with sed, with (my) command line syntax above, or with my > understanding of what should work when? > The difference in behaviour you are seeing results from the difference in the way cmd and bash interpret command lines and pass the resulting arguments to the specified commands. Compare: C:\>E:\cygwin\bin\echo.exe '/^ .*$/d' / .*$/d C:\> to: mks ~ $ /cygdrive/e/cygwin/bin/echo.exe '/^ .*$/d' /^ .*$/d mks ~ $ As you can see, the '^' isn't passed to echo.exe by cmd. I'm not really sure but I think cmd doesn't treat single quotes as quoting characters - at least not in the way bash does. If you use double quotes, it shout work in cmd: C:\>E:\cygwin\bin\echo.exe "/^ .*$/d" /^ .*$/d C:\> BTW: '/^ /d' shoud be enough to achieve what you are trying to. Regards mks -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/