AWK from a batch file

Matthew Swanson matthew@hmnetonline.com
Tue Jul 28 23:24:00 GMT 2009


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?  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?

Thanks for any help or suggestions!


--
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