Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Sep 2017 20:18:38 +0200
From:      Polytropon <>
To:        Ernie Luzar <>
Cc:        "" <>
Subject:   Re: awk help
Message-ID:  <>
In-Reply-To: <>
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Sun, 10 Sep 2017 09:32:02 -0400, Ernie Luzar wrote:
> Hello list;
> I wrote the following script to read a hosts file I downloaded
> containing known bad sex domain names intended for addition to
> /etc/hosts file. This script drops some useless records and builds
> a local-zone: record for input to unbound. The file contains 55,000
> records and this script takes 7 minutes to process it.
> I know awk can do this same thing must faster. I have searched awk
> and can not find any reference that would do what the tr '\r' ' '`
> command does.

I'd simply drop the ^Ms in a first step, then continue processing
with awk, writing the output to the desired file:

	cat input.txt | tr -d '\r' | awk '
		# ...
		# your awk code here
		# ...
	' > output.txt

You can use variables or command line parameters for input.txt and
output.txt to increase modularity.

NB: Useless use of "cat". ;-)

> Would some one point me to documentation with example of how to get
> the same result with awk as the tr '\r' ' '` command does.

Why do you want to replace the \r with a space? Just delete it,
nobody (except people in "Windows" land) actually need it! :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

Want to link to this message? Use this URL: <>