Assume I want to call gawk from DOS batch script.
I mean to gawk for windows available from here:
http://gnuwin32.sourceforge.net/packages/gawk.htm
I found samples like
@echo off & setlocal enableextensions
gawk 'BEGIN{printf"%%s\n",4/7}'
endlocal & goto :EOF
....but they don't work. I get an error:
gawk: 'BEGIN{printf%s\n,4/7}'
gawk: ^ invalid char ''' in expression
What do I have to change?
Calling gawk from DOS batch script?
Moderator: DosItHelp
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Calling gawk from DOS batch script?
Either have a line in your batch like
or
Code: Select all
set path=%path%;"C:\path\to\gawk.exe"
or
Code: Select all
start "" /b gawk 'BEGIN{printf"%%s\n",4/7}'
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Calling gawk from DOS batch script?
Also, in Windows, you need double quotes around your gawk command.
Try
Try
Code: Select all
gawk "BEGIN{printf\""%%s\n\"",4/7}"