fixunix
Tags Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

AWK for Windows XP? - MS-DOS

This is a discussion on AWK for Windows XP? - MS-DOS ; Hello there, Guys I need to run an awk script under Windows and therefore I am searching for awk command interpreter that works in Windows XP/2003. Is there awk for Windows environment? (I do not want to use Cygwin). Thanks...


Fix Unix > Microsoft Windows > MS-DOS > AWK for Windows XP?

Reply
 
LinkBack Tools
  #1  
Old 03-26-2007, 07:42 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default AWK for Windows XP?

Hello there,

Guys I need to run an awk script under Windows and therefore I am
searching for awk command interpreter that works in Windows XP/2003.

Is there awk for Windows environment? (I do not want to use Cygwin).

Thanks
Reply With Quote
  #2  
Old 03-26-2007, 07:51 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

aleu@vp.pl wrote:
> Hello there,
>
> Guys I need to run an awk script under Windows and therefore I am
> searching for awk command interpreter that works in Windows XP/2003.
>
> Is there awk for Windows environment? (I do not want to use Cygwin).
>


http://gnuwin32.sourceforge.net/packages/gawk.htm
http://unxutils.sourceforge.net/

--
Greetings
Matthias
Reply With Quote
  #3  
Old 03-26-2007, 07:58 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Matthias Tacke wrote:
>
> http://gnuwin32.sourceforge.net/packages/gawk.htm
> http://unxutils.sourceforge.net/


Matthias,

Thanks a million for this links. I have tried the following command:

C:\test>cat test.txt | gawk '{ print $11 }'
gawk: cmd. line:1: '{
gawk: cmd. line:1: ^ invalid char ''' in expression
cat: write error: Invalid argument

What am I doing wrong here? I want to display the 11th column of the
test.txt file.

Regards,
Aleu
Reply With Quote
  #4  
Old 03-26-2007, 08:01 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

On Mon, 26 Mar 2007 15:42:31 -0400, "aleu@vp.pl" wrote:

>Hello there,
>
>Guys I need to run an awk script under Windows and therefore I am
>searching for awk command interpreter that works in Windows XP/2003.
>
>Is there awk for Windows environment? (I do not want to use Cygwin).


gawk -

It what you would get with Cygwin or Linux, except a couple of *ix
pipe features don't work.


--
T.E.D. (tdavis@gearbox.maem.umr.edu)
Remove "gearbox.maem." from address - that one is dead
Reply With Quote
  #5  
Old 03-26-2007, 08:54 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

aleu@vp.pl wrote:
> Matthias Tacke wrote:
>>
>> http://gnuwin32.sourceforge.net/packages/gawk.htm
>> http://unxutils.sourceforge.net/

>
> Matthias,
>
> Thanks a million for this links. I have tried the following command:
>
> C:\test>cat test.txt | gawk '{ print $11 }'
> gawk: cmd. line:1: '{
> gawk: cmd. line:1: ^ invalid char ''' in expression
> cat: write error: Invalid argument
>
> What am I doing wrong here? I want to display the 11th column of the
> test.txt file.
>

Hi Aleu,
the single quotes have no special meaning in the cmd shell. Replace them
with double quotes.

Btw the command doesn't get the 11 line but the elenth word/token of the
lines, but I'm no awk guru ;-)

A pure batch soluition to print the eleventh line:

set x=
for /f "skip=10 delims=" %A in (test.txt) do @if not defined x
(@echo/%A)&set x=x

That are two lines for direct input to the shell.

--
Greetings
Matthias
Reply With Quote
  #6  
Old 03-27-2007, 01:33 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

On Mon, 26 Mar 2007 15:58:51 -0400, "aleu@vp.pl" wrote:

>Matthias Tacke wrote:
>>
>> http://gnuwin32.sourceforge.net/packages/gawk.htm
>> http://unxutils.sourceforge.net/

>
>Matthias,
>
>Thanks a million for this links. I have tried the following command:
>
>C:\test>cat test.txt | gawk '{ print $11 }'
>gawk: cmd. line:1: '{
>gawk: cmd. line:1: ^ invalid char ''' in expression
>cat: write error: Invalid argument
>
>What am I doing wrong here? I want to display the 11th column of the
>test.txt file.
>


In Windows, it's
awk "{print $11}" test.txt

Even in Unix, that is a misuse of cat - awk scripts take filenames as
arguments, and can be much more useful if the file is passed as an
argument since the FILENAME variable is then the name of the file
being processed, multiple files can be distinguished from each other,
and the input file can even be determined in a BEGIN{} block.

Another interesting point about gawk and Windows: if a filespec is to
be interpreted by gawk, use / as the directory separator (inside
scripts, and as the argument to -f on the command line) but if they
are to processed by the command interpreter, specifically the files
passed as arguments to the program, use \ - use \\ in strings literal
that are to be passed as part of a system() or command | getline
construct.

--
T.E.D. (tdavis@gearbox.maem.umr.edu) Remove "gearbox.maem" to get real address - that one is dead
Reply With Quote
  #7  
Old 03-27-2007, 03:33 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

aleu@vp.pl wrote:
> Guys I need to run an awk script under Windows and therefore I am
> searching for awk command interpreter that works in Windows XP/2003.


878915 Oct 25 2003 ftp://garbo.uwasa.fi/win95/unix/UnxUpdates.zip
UnxUpdates.zip Updates for UnxUtils GNU utilities for native Win32

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
Reply With Quote
  #8  
Old 03-27-2007, 04:09 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Matthias Tacke wrote:
> aleu@vp.pl wrote:
> > Matthias Tacke wrote:
> >>
> >> http://gnuwin32.sourceforge.net/packages/gawk.htm
> >> http://unxutils.sourceforge.net/

> >
> > Matthias,
> >
> > Thanks a million for this links. I have tried the following command:
> >
> > C:\test>cat test.txt | gawk '{ print $11 }'
> > gawk: cmd. line:1: '{
> > gawk: cmd. line:1: ^ invalid char ''' in expression
> > cat: write error: Invalid argument
> >
> > What am I doing wrong here? I want to display the 11th column of the
> > test.txt file.
> >

> Hi Aleu,
> the single quotes have no special meaning in the cmd shell. Replace them
> with double quotes.
>
> Btw the command doesn't get the 11 line but the elenth word/token of the
> lines, but I'm no awk guru ;-)
>
> A pure batch soluition to print the eleventh line:
>
> set x=
> for /f "skip=10 delims=" %A in (test.txt) do @if not defined x
> (@echo/%A)&set x=x
>
> That are two lines for direct input to the shell.


I wonder if OP wanted the "11th column" or 11th line?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Reply With Quote
  #9  
Old 03-27-2007, 09:27 AM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Todd Vargo wrote:
> Matthias Tacke wrote:
>> aleu@vp.pl wrote:
>>> What am I doing wrong here? I want to display the 11th column of the
>>> test.txt file.

....
> I wonder if OP wanted the "11th column" or 11th line?
>

Don't know why I misread that :-(

in pure batch this is:
for /f "tokens=11" %A in (test.txt) do @echo/%A

--
Greetings
Matthias
Reply With Quote
  #10  
Old 03-27-2007, 01:40 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Matthias Tacke wrote:
> Todd Vargo wrote:
>> Matthias Tacke wrote:
>>> aleu@vp.pl wrote:
>>>> What am I doing wrong here? I want to display the 11th column of the
>>>> test.txt file.

> ...
>> I wonder if OP wanted the "11th column" or 11th line?
>>

> Don't know why I misread that :-(
>
> in pure batch this is:
> for /f "tokens=11" %A in (test.txt) do @echo/%A
>

Hi guys,

Yes, I wanted the 11th column.

Thanks a million.

Regards,
Aleu
Reply With Quote
  #11  
Old 03-27-2007, 01:41 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Ted Davis wrote:
> In Windows, it's
> awk "{print $11}" test.txt
>
> Even in Unix, that is a misuse of cat - awk scripts take filenames as
> arguments, and can be much more useful if the file is passed as an
> argument since the FILENAME variable is then the name of the file
> being processed, multiple files can be distinguished from each other,
> and the input file can even be determined in a BEGIN{} block.
>
> Another interesting point about gawk and Windows: if a filespec is to
> be interpreted by gawk, use / as the directory separator (inside
> scripts, and as the argument to -f on the command line) but if they
> are to processed by the command interpreter, specifically the files
> passed as arguments to the program, use \ - use \\ in strings literal
> that are to be passed as part of a system() or command | getline
> construct.
>

Thanks for the clarification.
Reply With Quote
  #12  
Old 03-27-2007, 01:42 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Timo Salmi wrote:
> aleu@vp.pl wrote:
>> Guys I need to run an awk script under Windows and therefore I am
>> searching for awk command interpreter that works in Windows XP/2003.

>
> 878915 Oct 25 2003 ftp://garbo.uwasa.fi/win95/unix/UnxUpdates.zip
> UnxUpdates.zip Updates for UnxUtils GNU utilities for native Win32
>
> All the best, Timo
>

Thanks, this is precisely what I was looking for.

Regards,
Aleu
Reply With Quote
  #13  
Old 03-27-2007, 01:43 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

Matthias Tacke wrote:
> in pure batch this is:
> for /f "tokens=11" %A in (test.txt) do @echo/%A


Hmm, I am guessing that this will be more efficient in awk. Am I right?
Reply With Quote
  #14  
Old 03-27-2007, 02:21 PM
Junior Member
 
Join Date: Sep 2009
Posts: 0
Default Re: AWK for Windows XP?

aleu@vp.pl wrote:
> Matthias Tacke wrote:
>> in pure batch this is:
>> for /f "tokens=11" %A in (test.txt) do @echo/%A

>
> Hmm, I am guessing that this will be more efficient in awk. Am I right?


Maybe, depends on preferences, the environment, size and structure of the file.

--
Greetings
Matthias
Reply With Quote