delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/28/13:02:46

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Tue, 28 Jul 2009 19:02:18 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: AWK from a batch file
Message-ID: <20090728170218.GW18621@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000001ca0fa2$62df2430$289d6c90$@com>
MIME-Version: 1.0
In-Reply-To: <000001ca0fa2$62df2430$289d6c90$@com>
User-Agent: Mutt/1.5.19 (2009-02-20)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jul 28 11:42, Matthew Swanson wrote:
> I am attempting to run AWK in a bash window through a Windows batch file.  I
> am using:
> 
> echo awk -v FS=',' -v OFS=',' '^{ > awk.s
> echo  	if ^($2 ~ /^^[0-9]*$/^)>> awk.s
> echo 		print $0 ^>^> "good_file.txt">> awk.s
> echo 	else>> awk.s
> echo 		print $0 ^>^> "bad_file.txt">> awk.s
> echo ^}' input_file.txt>> awk.s
> 
> I am having two problems:
> 
> 1. I cannot get awk.s to run successfully.  If I call it directly after
> associating .s files with bash, it says awk: command not found.  I get a
> similar error if I call "c:\cygwin\bin\bash.exe -c ./awk.s"  How should I be
> executing awk.s from my batch file?

  chmod +x awk.s

I found a couple postings, but they all
> refer to interpreters in c:\cygwin\bin which aren't present.
> 
> 2. This may be a question for another forum, but I thought I would include
> it here, too, in hopes of getting an answer.  The script, awk.s, that is
> created in my batch file, when run directly in cygwin,  displays " ' for
> reading (No such file or directory) 'input_file.txt"  If you manually edit
> awk.s and remove the trailing carriage return, it executes successfully.
> How can I get the batch file to not include a trailing carriage return at
> the end of the file?

That's cmd for you.  Convert your bat file to a bash shell script and
use only binary mounts.  Otherwise, use d2u from the cygutils package.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019