Home > Archive > AWK > May 2005 > -v var=<path> on windows
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
-v var=<path> on windows
|
|
| Lorenz Lenhardt 2005-05-13, 3:58 pm |
| 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
| |
| Ted Davis 2005-05-13, 3:58 pm |
| On 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.
| |
|
| "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?
--
|
|
|
|
|