AWK from a batch file
Mark J. Reed
markjreed@gmail.com
Wed Jul 29 16:25:00 GMT 2009
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
More information about the Cygwin
mailing list