Code Comments
Programming Forum and web based access to our favorite programming groups.Hi all, I'm running the gnuwin32 port of gawk 3.1.3 on win2k. Im trying to pass a path to a gawk variable I know that I need to escape the backslashes like gawk -v var="c:\\path\\including blanks\\to\\file" ... My problem now is that the path I want to pass to gawk comes from a batch file parameter gawk -v var="%1" As expected gawk issues "warning: escape sequence '\x' treated as plain 'x'" if %1 contains a backslash. Does anyone know a way around this? TIA Lorenz
Post Follow-up to this messageOn Thu, 12 May 2005 10:25:34 +0200, Lorenz Lenhardt <lorenz@famlen.de>
wrote:
>Hi all,
>
>I'm running the gnuwin32 port of gawk 3.1.3 on win2k.
>
>Im trying to pass a path to a gawk variable
>
>I know that I need to escape the backslashes like
>
> gawk -v var="c:\\path\\including blanks\\to\\file" ...
>
>My problem now is that the path I want to pass to gawk comes from a
>batch file parameter
>
> gawk -v var="%1"
>
>As expected gawk issues "warning: escape sequence '\x' treated as
>plain 'x'" if %1 contains a backslash.
>
>
>Does anyone know a way around this?
>
awk "BEGIN{var=ARGV[1]; ARGV[1]=\"\"; ARGC--;print var}" %1
all one line - with or without "" around the string. Of course, in a
real-world program, sanity checking would be needed and also perhaps
more sophisticated ARGV/ARGC handling
--
T.E.D. (tdavis@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.
Post Follow-up to this message"Lorenz Lenhardt" <lorenz@famlen.de> wrote in message news:6046819ss5asp8ksf5mvmb0iu78tnstf7r@ 4ax.com... > Hi all, > > I'm running the gnuwin32 port of gawk 3.1.3 on win2k. > > Im trying to pass a path to a gawk variable > > I know that I need to escape the backslashes like > > gawk -v var="c:\\path\\including blanks\\to\\file" ... > > My problem now is that the path I want to pass to gawk comes from a > batch file parameter > > gawk -v var="%1" > > As expected gawk issues "warning: escape sequence '\x' treated as > plain 'x'" if %1 contains a backslash. > > > Does anyone know a way around this? > > > TIA Lorenz one way: set VAR1=%1 gawk -v vv="VAR1" .... var=ENVIRON[vv]; ... -- pop is Mark If all is not lost, where is it? --
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.