Problem with ' 
Author Message
 Problem with '

Hi,
I would like to run

gawk '{print}' data.txt

on a Windows Dos Prompt using Gawk 3.0.3 (I got the binary from the
internet, don't know where). I get the following answer:

gawk: cmd. line:1: '{print}'
gawk: cmd. line:1: ^ Invalid char ''' in expression

OK. Trying

gawk '{print}' data.txt

it does the expected.
But now I want to run

gawk 'BEGIN {FS=";"} {print $1}' data.csv

which doesn't work like in the first run. Then trying

In:
gawk "BEGIN {FS=";"} {print $1}" data.csv
Out:
gawk: cmd. line:1: BEGIN {FS=;} {print $1}
gawk: cmd. line:1:           ^ parse error

Trying ' or ` or instead " in the field separator statement
don't work to. I am frustrated.

Can you help me?

Karsten.



Sun, 28 Dec 2003 23:29:33 GMT  
 Problem with '
Karsten Weinert schrieb:

Quote:

> Hi,
> I would like to run

> gawk '{print}' data.txt

> on a Windows Dos Prompt using Gawk 3.0.3 (I got the binary from the
> internet, don't know where). I get the following answer:

> gawk: cmd. line:1: '{print}'
> gawk: cmd. line:1: ^ Invalid char ''' in expression

> OK. Trying

> gawk '{print}' data.txt

> it does the expected.
> But now I want to run

> gawk 'BEGIN {FS=";"} {print $1}' data.csv

> which doesn't work like in the first run. Then trying

> In:
> gawk "BEGIN {FS=";"} {print $1}" data.csv
> Out:
> gawk: cmd. line:1: BEGIN {FS=;} {print $1}
> gawk: cmd. line:1:           ^ parse error

> Trying ' or ` or instead " in the field separator statement
> don't work to. I am frustrated.

> Can you help me?

> Karsten.

write your {print} into a file e.g. named action.awk and run gawk with a
-f
switch

gawk -f action.awk data.txt

that should do.
it#s not possible to use ticks on the command line interface of windows.

cheers volker

--



Sun, 28 Dec 2003 23:44:04 GMT  
 Problem with '

Quote:

>Hi,
>I would like to run

>gawk '{print}' data.txt

>on a Windows Dos Prompt using Gawk 3.0.3 (I got the binary from the
>internet, don't know where). I get the following answer:

>gawk: cmd. line:1: '{print}'
>gawk: cmd. line:1: ^ Invalid char ''' in expression

>OK. Trying

>gawk '{print}' data.txt

>it does the expected.

I assume you meant to use double quotes instead of single quotes here.

- Show quoted text -

Quote:
>But now I want to run

>gawk 'BEGIN {FS=";"} {print $1}' data.csv

>which doesn't work like in the first run. Then trying

>In:
>gawk "BEGIN {FS=";"} {print $1}" data.csv
>Out:
>gawk: cmd. line:1: BEGIN {FS=;} {print $1}
>gawk: cmd. line:1:           ^ parse error

>Trying ' or ` or instead " in the field separator statement
>don't work to. I am frustrated.

>Can you help me?

It depends on which version of DOS you are using.  This has evolved a lot
over the years.  It didn't use to work at all.  However, the following
does, amazingly enough, work under Win98, using the Cygwin version of GAWK
3.1:

C:> gawk "BEGIN {\"/inet/tcp/0/unixhost/daytime\" |& getline;print}"

The trick is that in earlier versions of DOS, COMMAND.COM metas, such as
the | symbol, were still intercepted by the shell (in command lines such as
the above).  I.e., the \ escape wasn't handled properly.  They (the
geniuses in Redmond) seem to have fixed this somewhere along the way.

But, all in all, the advice given by the other poster to put your script in
a file, is good advice, especially under DOS.  However, it is nice to be
able to do it on the command line if you can.



Mon, 29 Dec 2003 01:37:42 GMT  
 Problem with '
Hello!

Like one poster mentioned, even in the newest Dosbox (Win2000) you've to ESCape
the double-quote characters inside an one-line AWK script with a back-slash. Then
it works pretty well, though. So for example you could write like this:
  dir /b | gawk "{system(\"ren \" $0 \" \" tolower($0))}"

BTW, also the newest GNU AWK v3.1.x can be run as a stand-alone exe (194 KB) via
http://gnuwin32.sourceforge.net

MfG, Dave

--
__________________________________________________________
News suchen, lesen, schreiben mit http://newsgroups.web.de



Mon, 29 Dec 2003 01:53:19 GMT  
 Problem with '
Quote:

>I would like to run

>gawk '{print}' data.txt

>on a Windows Dos Prompt using Gawk 3.0.3 (I got the binary from the
>internet, don't know where). I get the following answer:

>gawk: cmd. line:1: '{print}'
>gawk: cmd. line:1: ^ Invalid char ''' in expression

...

Others have suggested workarounds for dealing with COMMAND.COM or CMD.EXE.
If you want a good command line interface, consider downloading and
installing zsh (ftp://ftp.blarg.net/users/amol/zsh) - it's not the latest
version, but it's decent, costs less than MKS, isn't a C shell clone, and
doesn't require Cygwin's idiosyncrasies.



Mon, 29 Dec 2003 02:56:08 GMT  
 Problem with '

...

Quote:
>Others have suggested workarounds for dealing with COMMAND.COM or CMD.EXE.
>If you want a good command line interface, consider downloading and
>installing zsh (ftp://ftp.blarg.net/users/amol/zsh) - it's not the latest
>version, but it's decent, costs less than MKS, isn't a C shell clone, and
>doesn't require Cygwin's idiosyncrasies.

What are Cygwin's "idiosyncrasies"?


Mon, 29 Dec 2003 05:52:19 GMT  
 Problem with '

Quote:


...
>>doesn't require Cygwin's idiosyncrasies.

>What are Cygwin's "idiosyncrasies"?

Aside from the baggage of Cygwin's directory tree mostly following the File
System Hierarchy standard, with etc, man, share and so forth (bin is full of
useful stuff), Cygwin's drive letter handling is a departure from
DOS/Windows standard syntax. Isn't the C: drive //c, the D: drive //d, etc?
The zsh implementation to which I gave a link uses C:, D: etc. (like MKS's
shells). Is it a big deal? Matter of opinion.

Then there's a really nice facility in zsh: AUTO_CD, with which zsh
interprets drive/directory names entered alone as implied cd commands. Handy
for anyone coming from DOS/Windows.



Mon, 29 Dec 2003 08:00:18 GMT  
 Problem with '
...

Quote:
> . . . Isn't the C: drive file://c, the D: drive file://d, etc?


the evil empire's news reader.


Mon, 29 Dec 2003 08:20:15 GMT  
 Problem with '

Quote:


>...
>> . . . Isn't the C: drive file://c, the D: drive file://d, etc?


>the evil empire's news reader.

Actually, in the current version, it is /cygdrive/c/...


Mon, 29 Dec 2003 08:38:14 GMT  
 Problem with '

Quote:



> >...
> >> . . . Isn't the C: drive file://c, the D: drive file://d, etc?


> >the evil empire's news reader.

> Actually, in the current version, it is /cygdrive/c/...

And you're quite able to do  cd c:/temp    if you want, in cygwin.....

Which (IMO) is better than having to do a CD plus a drive assignment in DOS.



Mon, 29 Dec 2003 15:43:42 GMT  
 Problem with '

Quote:






>> >...
>> >> . . . Isn't the C: drive file://c, the D: drive file://d, etc?


>> >the evil empire's news reader.

>> Actually, in the current version, it is /cygdrive/c/...

>And you're quite able to do  cd c:/temp    if you want, in cygwin.....

>Which (IMO) is better than having to do a CD plus a drive assignment in DOS.

In fact, it looks like you can use ordinary DOS notation just about
everywhere, with the exception that you should use front slashes instead of
backslashes, because backslashes get interpreted by the shell.


Tue, 30 Dec 2003 00:36:42 GMT  
 Problem with '

Quote:


...
>> Actually, in the current version, it is /cygdrive/c/...

Compared to '//c' this doesn't strike me as progress - more characters to
type, and it must have meant having to fix old scripts. Is '/cygdrive' an
actual directory entry or is it a reserved symbol? Just curious.

Quote:
>And you're quite able to do  cd c:/temp    if you want, in cygwin.....

Is this specific to the cd command? Does it work with other Cygwin commands
like 'mkdir d:/foobar' or 'gawk -f x:/y/z' ? If it does, great - they
finally fixed my biggest gripe with it. If not, . . .

More to the point, what does pwd show/PWD hold? c:/temp or /cygdrive/c/temp?
If you start on drive C: and issue the following commands in Cygwin's bash

cd /temp
cd d:/foobar
cd c:

what's your pwd? For that matter, where do the following commands leave you?

cd /cygdrive/c/..
cd /cygdrive/c/../..
cd /cygdrive/c/../d
cd /
cd /cygdrive

The problem with Cygwin's approach is that you need to think about what each
of these mean.

Quote:
>Which (IMO) is better than having to do a CD plus a drive assignment in

DOS.

Well, it's not like there weren't a sh*tload of small .COM programs that
would change both drive and directory that appeared in the PC-related
magazines shortly after PC/MS-DOS 2.0 appeared. I still use one called
dc.com that was generated from a 20 (or so) line DEBUG script. There were a
number of utilities like this that Microsoft never saw fit to include in
DOS/Windows - probably because they were all free, so no competitor to
snuff.

If you want to change drive as well as directory, you're right. However,
there are times in DOS (and OS/2 to be thorough) when you may only want to
change the current directory on another drive while remaining on the current
drive. Given the way network drives are mapped in DOS/Windows(& OS/2)
machines, if I'm working with files on two different network drives using a
program on a local drive, I may not want to change drives, but I may very
much want to change directories on the network drives.

cd p:\a\b\c\d\1
cd q:\w\x\y\z\1
someprog p:fileA q:fileA
someprog p:fileZ q:fileZ
cd p:\a\b\c\d\2
cd q:\1\2\3\4\2
someprog p:fileA q:fileA
someprog p:fileZ q:fileZ

has it's advantages in some situations. Personally, I prefer DOS-like drive
letter semantics - the OS keeps track of different current directories on
each lettered drive - to UNC full pathnames.

Cygwin does present a somewhat steeper learning curve than other *nixlike
alternatives. If one already knows *nix, it may be the best choice. If one
has only used Windows, it's not the best choice (IMO).



Tue, 30 Dec 2003 01:14:03 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Problem with ''Mailbox''

2. Problem w/ 'window' property

3. Problem with 'LIKE'

4. Problems with 'LIKE'

5. Problem with 'filter'

6. Problem with 'Privates' Re-visited

7. Problem with 'VALID' clause

8. problems with 'peak detection'

9. GNAT-Problem '+'-operator with Count

10. Problem with 'get_immediate'

11. HTTPLib and POST problem with '?'

12. newbie problem with 'ord' function

 

 
Powered by phpBB® Forum Software