[SWLUG] Awk is driving me MAD!
Justin Mitchell
justin at discordia.org.uk
Wed Jun 11 09:02:59 UTC 2003
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
awk '!/^#/{printf("%s IN A %s\n, $2, $1);} /etc/hosts
Which makes it run the code only for lines that do not start with a #
More information about the Swlug
mailing list