FS = , is error?

  • Follow


Can anyone tell me what's wrong with this command?

C:\Users\Owner>gawk "BEGIN { FS = , }"
gawk: cmd. line:1: BEGIN { FS = , }
gawk: cmd. line:1:              ^ parse error


0
Reply Owner 4/12/2010 3:43:11 PM

Owner said the following on 4/12/2010 10:43 AM:
> Can anyone tell me what's wrong with this command?
>
> C:\Users\Owner>gawk "BEGIN { FS = , }"
> gawk: cmd. line:1: BEGIN { FS = , }
> gawk: cmd. line:1:              ^ parse error
>
>
The comma needs to be in quotes:
"BEGIN { FS = \",\" }"

-- 
(^\pop/^)
I'm lost... I've gone to look for myself.
If I should return before I get back, keep me here.
--
0
Reply pop 4/12/2010 4:13:14 PM


Owner schrieb:
> Can anyone tell me what's wrong with this command?
> 
> C:\Users\Owner>gawk "BEGIN { FS = , }"

You use the wrong OS.

But more seriously; strings need to be quoted as in (Note: this is Unix
shell syntax)

  gawk 'BEGIN { FS = "," }'

Problem is that on your OS you seem to need using double quotes to embed
the awk program, which probably forces you to escape all double quotes
that appear around any strings in the awk program, probably

  gawk "BEGIN { FS = \",\" }"

or you have to put your awk code in a file, say a_file, and call if as

  gawk -f a_file

where you avoided the quoting issue on your OS. Another option in this
specific case is that you use an awk command line option to set the
variable FS;

  gawk -F, "..."

Again, the comma might need some escaping/quoting on your OS.

Janis


> gawk: cmd. line:1: BEGIN { FS = , }
> gawk: cmd. line:1:              ^ parse error
> 
> 
0
Reply Janis 4/12/2010 4:19:52 PM

In article <hpvgr0$p5q$1@pop.motzarella.org>, pop  <p_o_p@hotmail.com> wrote:
>Owner said the following on 4/12/2010 10:43 AM:
>> Can anyone tell me what's wrong with this command?
>>
>> C:\Users\Owner>gawk "BEGIN { FS = , }"
>> gawk: cmd. line:1: BEGIN { FS = , }
>> gawk: cmd. line:1:              ^ parse error
>>
>>
>The comma needs to be in quotes:
>"BEGIN { FS = \",\" }"

True, but it is unlikely that the backslashes are right, since this
looks like DOS/Windows and backslashes aren't special in the commonly
available DOS/Windows shell(s) [COMMAND.COM and CMD.EXE].

I think that what OP was really looking for was:

	C:\Users\Owner>gawk -F, ...

Note the lack of need for quoting.

-- 
(This discussion group is about C, ...)

Wrong.  It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

0
Reply gazelle 4/12/2010 4:21:18 PM

Kenny McCormack said the following on 4/12/2010 11:21 AM:
> In article<hpvgr0$p5q$1@pop.motzarella.org>, pop<p_o_p@hotmail.com>  wrote:
>> Owner said the following on 4/12/2010 10:43 AM:
>>> Can anyone tell me what's wrong with this command?
>>>
>>> C:\Users\Owner>gawk "BEGIN { FS = , }"
>>> gawk: cmd. line:1: BEGIN { FS = , }
>>> gawk: cmd. line:1:              ^ parse error
>>>
>>>
>> The comma needs to be in quotes:
>> "BEGIN { FS = \",\" }"
>
> True, but it is unlikely that the backslashes are right, since this
> looks like DOS/Windows and backslashes aren't special in the commonly
> available DOS/Windows shell(s) [COMMAND.COM and CMD.EXE].
>
> I think that what OP was really looking for was:
>
> 	C:\Users\Owner>gawk -F, ...
>
> Note the lack of need for quoting.
>
Partially true: backslashes won't work if the FS string contains a 
special character to windows. Otherwise, the backslashes are special to 
gawk since the entire string in windows is passed to gawk including all 
quotes (command.com and cmd.exe does not remove quotes but only ingnores 
what is between them)

-- 
(^\pop/^)
I'm lost... I've gone to look for myself.
If I should return before I get back, keep me here.
--
0
Reply pop 4/12/2010 4:31:29 PM

pop said the following on 4/12/2010 11:31 AM:
> Kenny McCormack said the following on 4/12/2010 11:21 AM:
>> In article<hpvgr0$p5q$1@pop.motzarella.org>, pop<p_o_p@hotmail.com>
>> wrote:
>>> Owner said the following on 4/12/2010 10:43 AM:
>>>> Can anyone tell me what's wrong with this command?
>>>>
>>>> C:\Users\Owner>gawk "BEGIN { FS = , }"
>>>> gawk: cmd. line:1: BEGIN { FS = , }
>>>> gawk: cmd. line:1: ^ parse error
>>>>
>>>>
>>> The comma needs to be in quotes:
>>> "BEGIN { FS = \",\" }"
>>
>> True, but it is unlikely that the backslashes are right, since this
>> looks like DOS/Windows and backslashes aren't special in the commonly
>> available DOS/Windows shell(s) [COMMAND.COM and CMD.EXE].
>>
>> I think that what OP was really looking for was:
>>
>> C:\Users\Owner>gawk -F, ...
>>
>> Note the lack of need for quoting.
>>
> Partially true: backslashes won't work if the FS string contains a
> special character to windows. Otherwise, the backslashes are special to
> gawk since the entire string in windows is passed to gawk including all
> quotes (command.com and cmd.exe does not remove quotes but only ingnores
what is between them) <-with certain exceptions such as expanding env. 
vars in %s

-- 
(^\pop/^)
I'm lost... I've gone to look for myself.
If I should return before I get back, keep me here.
--
0
Reply pop 4/12/2010 4:34:55 PM

In article <hpvht7$2fk$1@pop.motzarella.org>, pop  <p_o_p@hotmail.com> wrote:
....
>> True, but it is unlikely that the backslashes are right, since this
>> looks like DOS/Windows and backslashes aren't special in the commonly
>> available DOS/Windows shell(s) [COMMAND.COM and CMD.EXE].
....
>Partially true: backslashes won't work if the FS string contains a 
>special character to windows. Otherwise, the backslashes are special to 
>gawk since the entire string in windows is passed to gawk including all 
>quotes (command.com and cmd.exe does not remove quotes but only ingnores 
>what is between them)

I assume that, like me, you didn't do any testing before posting.  Quite
possibly because, like me, you don't have actually have a GAWK.EXE on
your DOS/Windows system to test with.  And, like me, you realize that in
DOS/Windows, the details of command line parsing are
application-specific.  I.e., each possible EXE file can do it differently.

Having said all that, I don't think that:

	gawk "BEGIN { FS=\",\"}"

under DOS/Windows is any more likely to work than:

	gawk 'BEGIN { FS=\",\"}'

is likely to work under Unix. I hope you can see what I mean and that I
don't have to explain further.

-- 
(This discussion group is about C, ...)

Wrong.  It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

0
Reply gazelle 4/12/2010 4:43:23 PM

On Mon, 12 Apr 2010 18:19:52 +0200, Janis Papanagnou wrote:

> Owner schrieb:
>> Can anyone tell me what's wrong with this command?
>> 
>> C:\Users\Owner>gawk "BEGIN { FS = , }"
> 
> You use the wrong OS.

winddows 7
> 
> But more seriously; strings need to be quoted as in (Note: this is Unix
> shell syntax)
> 
>   gawk 'BEGIN { FS = "," }'
> 
> Problem is that on your OS you seem to need using double quotes to embed
> the awk program, which probably forces you to escape all double quotes
> that appear around any strings in the awk program, probably
> 
>   gawk "BEGIN { FS = \",\" }"

thanks it worked!!
> 
> or you have to put your awk code in a file, say a_file, and call if as
> 
>   gawk -f a_file
> 
> where you avoided the quoting issue on your OS. Another option in this
> specific case is that you use an awk command line option to set the
> variable FS;
> 
>   gawk -F, "..."

used to use this option
> 
> Again, the comma might need some escaping/quoting on your OS.
> 
> Janis
> 
> 
>> gawk: cmd. line:1: BEGIN { FS = , }
>> gawk: cmd. line:1:              ^ parse error
>> 
>>

0
Reply Owner 4/12/2010 5:10:10 PM

Kenny McCormack said the following on 4/12/2010 11:43 AM:
> In article<hpvht7$2fk$1@pop.motzarella.org>, pop<p_o_p@hotmail.com>  wrote:
> ...
>> Partially true: backslashes won't work if the FS string contains a
>> special character to windows. Otherwise, the backslashes are special to
>> gawk since the entire string in windows is passed to gawk including all
>> quotes (command.com and cmd.exe does not remove quotes but only ingnores
>> what is between them)
>
> I assume that, like me, you didn't do any testing before posting.  Quite
> possibly because, like me, you don't have actually have a GAWK.EXE on
> your DOS/Windows system to test with.  And, like me, you realize that in
> DOS/Windows, the details of command line parsing are
> application-specific.  I.e., each possible EXE file can do it differently.
>
> Having said all that, I don't think that:
>
> 	gawk "BEGIN { FS=\",\"}"
>
> under DOS/Windows is any more likely to work than:
>
> 	gawk 'BEGIN { FS=\",\"}'
>
> is likely to work under Unix. I hope you can see what I mean and that I
> don't have to explain further.
>
Not to get into a "knowledge contest" but I do have gawk.exe on my 
windows system and have used (and tested) it for years so the solution 
as stated does work although there are other solutions that may work 
better under windows but the OP only wanted to know what was wrong with 
his command as presented and you gave a good workaround without quotes.

No disrespect intended or taken.

-- 
(^\pop/^)
I'm lost... I've gone to look for myself.
If I should return before I get back, keep me here.
--
0
Reply pop 4/12/2010 5:13:57 PM

Owner schrieb:
> On Mon, 12 Apr 2010 18:19:52 +0200, Janis Papanagnou wrote:
> 
>> Owner schrieb:
>>> Can anyone tell me what's wrong with this command?
>>>
>>> C:\Users\Owner>gawk "BEGIN { FS = , }"
>> You use the wrong OS.
> 
> winddows 7

In this respect WinDOS 7 is not really better than any other
WinDOS, I suppose; it's the WinDOS inherent quoting (and quote
expansion) philosophy that doesn't seem to have changed since
decades. (Might be different with so called '"Power" shell'?
Dunno. Nevermind.)

Janis
0
Reply Janis 4/12/2010 5:29:19 PM

In article <hpvkd2$l99$1@pop.motzarella.org>, pop  <p_o_p@hotmail.com> wrote:
....
>No disrespect intended or taken.

OK - likewise.

Incidentally, it does still stand that every EXE is potentially different.
I'm pretty sure that among the various {InsertNameOfUnixUtilHere}.EXEs
that I've downloaded over the years, I've seen lots of different command
line parsing methods and quirks.  Even among various GAWK.EXEs.  The
point is, there is no standard.

-- 
(This discussion group is about C, ...)

Wrong.  It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch revelations of the childhood
traumas of the participants...

0
Reply gazelle 4/12/2010 5:33:43 PM

10 Replies
271 Views

(page loaded in 0.072 seconds)

Similiar Articles:













7/22/2012 5:33:26 PM


Reply: