From owner-freebsd-questions@FreeBSD.ORG Wed May 18 18:20:06 2011 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66465106566C for ; Wed, 18 May 2011 18:20:06 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 2A4CD8FC08 for ; Wed, 18 May 2011 18:20:05 +0000 (UTC) Received: from SBHFISLREXT03 ([10.132.254.62]) by SCSFISLTC02 (8.14.3/8.14.3) with ESMTP id p4IIK53N009718; Wed, 18 May 2011 13:20:05 -0500 Received: from SBHFISLTCGW04.FNFIS.COM (Not Verified[10.132.248.123]) by SBHFISLREXT03 with MailMarshal (v6, 5, 4, 7535) id ; Wed, 18 May 2011 13:20:29 -0500 Received: from SBHFISLTCGW07.FNFIS.COM ([10.132.248.135]) by SBHFISLTCGW04.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 May 2011 13:20:05 -0500 Received: from dtwin ([10.132.254.136]) by SBHFISLTCGW07.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 18 May 2011 13:20:04 -0500 From: "Devin Teske" To: "'Gary Kline'" , "'FreeBSD Mailing List'" References: <20110518174141.GA62977@thought.org> In-Reply-To: <20110518174141.GA62977@thought.org> Date: Wed, 18 May 2011 11:19:21 -0700 Organization: Vicor, Inc. Message-ID: <000801cc1588$1cf81e20$56e85a60$@vicor.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 thread-index: AQNkwfLlwlcMMVgu7IE6EzX8THu0uZFhiWCw Content-Language: en-us X-OriginalArrivalTime: 18 May 2011 18:20:04.0634 (UTC) FILETIME=[35A05FA0:01CC1588] Cc: Subject: RE: kwik way? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2011 18:20:06 -0000 > -----Original Message----- > From: owner-freebsd-questions@freebsd.org [mailto:owner-freebsd- > questions@freebsd.org] On Behalf Of Gary Kline > Sent: Wednesday, May 18, 2011 10:42 AM > To: FreeBSD Mailing List > Subject: kwik way? > > should i use tr or sed to turn "\t" into " "? --i.e., tabs into spaces. Depends on how you do it in sed. The y/// operator is faster than s/// when transliterating a single character globally. If you use y/// instead of s///, then sed performance should be on-par with tr. Below are some performance metrics involving a 100,000 line contrived text file containing 1M tabs and 1.8M spaces: $ wc -l foo 100000 foo $ du -h foo 2.8M foo $ file foo foo: ASCII text $ time sh -c "sed -e 's/ / /g' < foo > bar" real 0m2.479s user 0m1.047s sys 0m0.105s $ md5 bar MD5 (bar) = f0187bcbc37cd6d84c6f5cadc6443843 $ time sh -c "tr '\t' ' ' < foo > bar" real 0m0.261s user 0m0.120s sys 0m0.026s $ md5 bar MD5 (bar) = f0187bcbc37cd6d84c6f5cadc6443843 $ time sh -c "sed -e 'y/ / /' < foo > bar" real 0m0.261s user 0m0.116s sys 0m0.087s $ md5 bar MD5 (bar) = f0187bcbc37cd6d84c6f5cadc6443843 -- Devin _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________