From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: How to run an awk command on file in emacs - using minGW on Windows Date: Tue, 17 Sep 2013 14:19:56 +0300 Message-ID: <83bo3rpueb.fsf@gnu.org> References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1379416853 3251 80.91.229.3 (17 Sep 2013 11:20:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2013 11:20:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 17 13:20:56 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VLtKw-0007HV-7X for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Sep 2013 13:20:54 +0200 Original-Received: from localhost ([::1]:40088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLtKv-0004en-Of for geh-help-gnu-emacs@m.gmane.org; Tue, 17 Sep 2013 07:20:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLtKc-0004dX-Ma for help-gnu-emacs@gnu.org; Tue, 17 Sep 2013 07:20:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLtKU-0003e7-BD for help-gnu-emacs@gnu.org; Tue, 17 Sep 2013 07:20:34 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:40022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLtKU-0003dk-3s for help-gnu-emacs@gnu.org; Tue, 17 Sep 2013 07:20:26 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MT900900OHGUL00@a-mtaout22.012.net.il> for help-gnu-emacs@gnu.org; Tue, 17 Sep 2013 14:19:59 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MT9009QFOTAMB70@a-mtaout22.012.net.il> for help-gnu-emacs@gnu.org; Tue, 17 Sep 2013 14:19:59 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93411 Archived-At: > Date: Tue, 17 Sep 2013 11:39:59 +0100 > From: Angus Comber > > 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. But I really suggest not to use MSYS tools from Emacs. There are native (MinGW) ports available.