From owner-freebsd-questions@freebsd.org Sun Sep 10 18:18:50 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 613F5E1F6E9 for ; Sun, 10 Sep 2017 18:18:50 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay14.qsc.de (mailrelay14.qsc.de [212.99.163.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA213811ED for ; Sun, 10 Sep 2017 18:18:49 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay14.qsc.de; Sun, 10 Sep 2017 20:18:39 +0200 Received: from r56.edvax.de (port-92-195-85-107.dynamic.qsc.de [92.195.85.107]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 4CFBC3CBF9; Sun, 10 Sep 2017 20:18:39 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id v8AIIcDa001983; Sun, 10 Sep 2017 20:18:38 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sun, 10 Sep 2017 20:18:38 +0200 From: Polytropon To: Ernie Luzar Cc: "freebsd-questions@freebsd.org" Subject: Re: awk help Message-Id: <20170910201838.88b15b21.freebsd@edvax.de> In-Reply-To: <59B53ED2.3000409@gmail.com> References: <59B53ED2.3000409@gmail.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay14.qsc.de with 847A9743A8D X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.1281 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Sep 2017 18:18:50 -0000 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: #!/bin/sh 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! :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...