AWK from a batch file

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Jul 28 23:33:00 GMT 2009


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



More information about the Cygwin mailing list