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 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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