following up a message from John Thompson to Holger Granholm:
JT> In a message to Jack Stein, Holger Granholm wrote re: Warp 3
JT> install
AR> I was looking for a quick way to add blank spaces for a left
AR> margin.
JT>
JS>I use GAWK or SED.
JT>
JS>GAWK '{print " "$0}' file.txt >lpt1
JT> [clip...]
JS>Look for:
JS>GAWK304D.ZIP GAWK Documentation (926K)
JS>GAWK304X.ZIP GAWK Text Processing Language for OS/2, DOS and
JS>WIN32. (435K)
JT>
HG> Ouch what a space filler on the HD.
JT> Yes, if all you're going to use gawk for is to add a few
JT> spaces to each line before you print.
No, that is incorrect. GAWK is NOT a space filler. I listed the file size
for the package, that includes all sorts of crap. The GAWK.EXE is not large:
gawk2156.exe ³ 126484³ 3/17/95³12:3
12k is not what I would call a space filler for a hard drive. One reason it
is so small, yet so powerful is it also uses EMX, like all good UNIX ports.
JT> But gawk is much more versatile than that, and worth having
JT> around for a variety of reasons despite the space it occupies.
John is SO correct here. You can add spaces to the front of every line
instantly, or, you can create your own relational databases with a little
effort. You can write applications with data entry. GAWK (and it's big
brother PERL) are not lightweight programs. They do light work, and heavy
duty work, whatever you need.
How about a filter to remove duplicate lines from a text file, say, your
keyboard buffer history file? Yep, GAWK will do that instantly, with a few
words:
gawk '$0!=lastline {print lastline=$0}' filename
For complicated stuff, you write your code in a file, and GAWK will read the
script file instead of just the command line.
I have 50 line AWK scripts that would take thousands of lines of C code, and a
ton of space to duplicate using something like the C language. Compared to C,
AWK is very simple to use, lots of the drudge work is done for you, as in most
high level languages. AWK is also a lot of fun to use, unlike compiled
languages.
JT> Or, you could just get "perl" and do away with both "sed"
JT> and "gawk..."
He's right there, but PERL is a bit more complicated to learn I think, but
well worth the effort. I haven't gotten into PERL myself, yet. I switched
pretty much to REXX before getting involved with PERL. I use REXX more than
AWK these days, but still use it for command line stuff. When I started with
REXX, I converted a lot of my GAWK scripts to REXX scripts, that's how I
learned REXX.
REXX is pretty good text processing language itself. You could also write a
rexx script to add spaces to the front of every line of a file, but not quite
as quick and easy as with GAWK.
/*addspace.cmd*/
do while lines(filename.txt)
say " " linein(filename.txt)
end
Thats not too difficult either. Just redirect the output to a file, or
directly to the printer, or use lineout() instead of say, and send it there
directly.
Jack
--- timEd/2-B11
140/1
278/111
* Origin: Jack's Free Lunch 4OS2 USR 56k Pgh Pa (412)492-0822 (1:129/171)
|