help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to run an awk command on file in emacs - using minGW on Windows


From: Angus Comber
Subject: Re: How to run an awk command on file in emacs - using minGW on Windows
Date: Tue, 17 Sep 2013 17:41:07 +0100

On 17 September 2013 12:19, Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Tue, 17 Sep 2013 11:39:59 +0100
> > From: Angus Comber <anguscomber@gmail.com>
> >
> > If I am visiting a file in emacs I want to be able to run a simple awk
> > command, eg
> >
> >     awk /Sam/ test.txt
> >
> > How would I construct this.
>
> "M-! awk /Sam/ test.txt" (without the quotes) works for me.
>
> > I tried:
> >
> >     m-! - to be able to run a shell cmd
> >
> >     awk '/Sam/' test.txt
> >
> > But then I get this error:
> >
> >     awk: c:/MinGW/msys/1.0/Sam/ { print }
> >     awk:  ^ syntax error
> >     awk: c:/MinGW/msys/1.0/Sam/ { print }
> >     awk:                        ^ syntax error
> >     errcount: 2
>
> You are using MSYS tools from a native Windows Emacs, and you are
> paying the price.
>
> > I also tried awk "/Sam/" test.txt and get same error.
>
> Right, MSYS does that with both flavors of quotes.
>
> > Running just awk '{ print }' test.txt works
>
> Because the argument doesn't start with a slash.
>
> > I am running on Windows 7 using minGW and my shell is set to:
> >
> >     echo %SHELL%
> >     C:/MinGW/msys/1.0/bin/bash.exe
>
> That's your problem: why do you set shell to the MSYS Bash?  I suggest
> not to do that.  Leave it at the default.
>
> > How do I escape the /Sam/ ?  It thinks it is part of the directory to the
> > exe I think?
>
> Yes.
>
> Try this:
>
>   awk ' /Sam/' test.txt
>
> i.e. an extra blank before the first slash.
>

*** The extra space fixes it.  That is not obvious.

>
> But I really suggest not to use MSYS tools from Emacs.  There are
> native (MinGW) ports available.
>
> *** But msys gives me my unix environment.  Are you saying install full
Cygwin?  Or just remove my %SHELL% env var?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]