[SWLUG] Awk is driving me MAD!
Gareth James Powell
gareth-j.powell at st.com
Wed Jun 11 10:35:58 UTC 2003
Hi again,
justin at discordia.org.uk wrote:
>
> On Wed, 2003-06-11 at 09:08, Gareth James Powell wrote:
> > dick at acm.org wrote:
> > > or: awk '{printf("%s IN A %s\n", $2, $1);}' /etc/hosts
>
> > ...as hosts on the works box I use has comment lines
>
> You dont need to use a sed, awk can execute commands only for lines that
> match certain patterns, so to extend dicks version
[snip]
Its a shell problem:
csh:
awk '/[^#]/{ printf("%s IN A %s\n", $2, $1);}' /etc/hosts
bash:
awk '!/^#/{printf("%s IN A %s\n", $2, $1);}' /etc/hosts
I think this kind of thing was the reason I gave up shell scripts for
anything 1x10-6 serious a long time ago!! Maybe when Linux takes over
the world we will only have to learn bash scripting. ;-)
Have a good day y'all!
Regards,
Gareth.
More information about the Swlug
mailing list