Hi Folks,
I appeal to the ALUG Linux Consulate to rescue me, a citizen of Linux, from a foriegn and dangerous land!
I want to experimentally try running gawk on a Win98 system (the background is that a friend, currently working in Africa and stuck with Windows, could have the daunting task of restructuring the records in a CSV file solved in an awk 2-liner, instead of pulling hair out trying to do it in FoxPro).
Since I've never tried running any GNU stuff on Windows, so cannot offer any advice based on experience, I thought I'd better acquire some before shooting my nouth off.
This I went to
http://gnuwin32.sourceforge.net/packages/gawk.htm
and downloaded the "Setup" package (a 6.6MB .exe file), planted it in [excuse my language]
C:\Program Files\GnuWin32\gawk
[maybe that was a mistake?] and ran the setup file
gawk-3.1.3-2.exe
All seemed to go smoothly, the files being installed in the above directory.
Then I tried (in a DOS box) to run
gawk '{print "Ted"}'
and got an error that the "'" character was illegal!
So I feel stuck! Has anyone been there and succeeded, and can offer advice?
With thanks, Ted.
PS If there are any FoxPro experts out there who could short-circuit the problem by advising how to do it in FoxPro, I can send a mini-example of the job that needs to be done. It's really simple, logically speaking, but has a twist which might mean a little neat footwork. In which case very many thanks for that!
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 05-Aug-06 Time: 21:03:11 ------------------------------ XFMail ------------------------------
On Sat, Aug 05, 2006 at 09:03:14PM +0100, Ted Harding wrote:
Since I've never tried running any GNU stuff on Windows, so cannot offer any advice based on experience, I thought I'd better acquire some before shooting my nouth off.
Hmmmn, I don't really know about your gawk problem. I'm guessing that DOS thinks ' is a special character of some kind, but another software package to consider is cygwin from http://www.cygwin.com/ it means you can run bash (and other GNU software, check the site for more details) on windows and it presents you with a unix/linux like environment running inside Windows, it should allow you to get a working awk.
Thanks Adam
(Ted Harding) wrote:
Hi Folks,
I appeal to the ALUG Linux Consulate to rescue me, a citizen of Linux, from a foriegn and dangerous land!
I want to experimentally try running gawk on a Win98 system (the background is that a friend, currently working in Africa and stuck with Windows, could have the daunting task of restructuring the records in a CSV file solved in an awk 2-liner, instead of pulling hair out trying to do it in FoxPro).
[SNIP]
On Windows, the editor PFE32 has a good macro/learning facility which may assist you here. See:
http://www.lancs.ac.uk/staff/steveb/cpaap/pfe/pfefiles.htm
Cheers, Laurie.
On 11-Aug-06 Laurie Brown wrote:
(Ted Harding) wrote:
Hi Folks,
I appeal to the ALUG Linux Consulate to rescue me, a citizen of Linux, from a foriegn and dangerous land!
I want to experimentally try running gawk on a Win98 system (the background is that a friend, currently working in Africa and stuck with Windows, could have the daunting task of restructuring the records in a CSV file solved in an awk 2-liner, instead of pulling hair out trying to do it in FoxPro).
[SNIP]
On Windows, the editor PFE32 has a good macro/learning facility which may assist you here. See:
http://www.lancs.ac.uk/staff/steveb/cpaap/pfe/pfefiles.htm
Cheers, Laurie.
Thanks for the pointer, Laurie! This looks a bit like 'vim' for Windows, perhaps plus a bit, according to the "Features":
http://www.lancs.ac.uk/staff/steveb/cpaap/pfe/features.htm
However, it doesn't look as though it would do the job in question (now thankfully solved diectly in FoxPro), which in 'awk' was a snip, namely (toy example):
data file (hh.dat):
1.1,1.2,1.3,1.4,1,hh1.1 2.1,2.2,2.3,2.4,2,hh2.1,hh2.2 3.1,3.2,3.3,3.4,6,hh3.1,hh3.2,hh3.3,hh3.4,hh3.5,hh3.6 4.1,4.2,4.3,4.4,4,hh4.1,hh4.2,hh4.3,hh4.4
where the 1st 4 (comma-sep) fields are data values, the 5th says how many instances of an "hh" there are, and the remainder are "hh" identifiers of hh's to which the data values apply. The problem is to split out the hh's into separate records, one for each hh.
Using 'awk':
cat hh.dat | awk 'BEGIN{FS=","} {nhh=$5; for(i=1;i<=nhh;i++){ hh=$(i+5); print($1 "," $2 "," $3 "," $4 "," hh) } }' 1.1,1.2,1.3,1.4,hh1.1 2.1,2.2,2.3,2.4,hh2.1 2.1,2.2,2.3,2.4,hh2.2 3.1,3.2,3.3,3.4,hh3.1 3.1,3.2,3.3,3.4,hh3.2 3.1,3.2,3.3,3.4,hh3.3 3.1,3.2,3.3,3.4,hh3.4 3.1,3.2,3.3,3.4,hh3.5 3.1,3.2,3.3,3.4,hh3.6 4.1,4.2,4.3,4.4,hh4.1 4.1,4.2,4.3,4.4,hh4.2 4.1,4.2,4.3,4.4,hh4.3 4.1,4.2,4.3,4.4,hh4.4
Could PFE32 do that? (Quote possibly 'vim' could do it, but I'd hate to write the macro!)
Cheers, Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 11-Aug-06 Time: 15:49:56 ------------------------------ XFMail ------------------------------