This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AWK from a batch file


On Tue, Jul 28, 2009 at 12:42 PM, 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

OK, so you are creating a bash script from CMD.  Invoking it outside
of Cygwin means the normal bash startup files are not run, so $PATH is
not set, so it can't find any commands.  Replace "awk" with "/bin/awk"
and you should be good, apart from the lack of execute permission.

The second problem is that CMD's "echo" appends carraige returns.
Add these commands to fix both that problem and the execute permission
one:

\cygwin\bin\d2u awk.s
\cygwin\bin\chmod +x awk.s

-- 
Mark J. Reed <markjreed@gmail.com>

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]