From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Ptmxi-0000F6-Cw for garchives@archives.gentoo.org; Sun, 27 Feb 2011 20:11:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 59C841C08F; Sun, 27 Feb 2011 20:10:01 +0000 (UTC) Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.122]) by pigeon.gentoo.org (Postfix) with ESMTP id 2BF8B1C089 for ; Sun, 27 Feb 2011 20:10:00 +0000 (UTC) X-Authority-Analysis: v=1.1 cv=3uSaImBeuprzHBlOOPjkqgu+7PcxSRW0m2Aphm9Zmck= c=1 sm=0 a=YShGzBUuvqEA:10 a=IkcTkHD0fZMA:10 a=2VaGs+wUE6jZKKQEApKsdQ==:17 a=ybZZDoGAAAAA:8 a=uG9w18Cd3bPZmEnVAkgA:9 a=wkTn_aNCqhJs6leskuUA:7 a=AGYethGVMsv1Tl4OR3HjD-OaFAkA:4 a=QEXdDO2ut3YA:10 a=qIVjreYYsbEA:10 a=2VaGs+wUE6jZKKQEApKsdQ==:117 X-Cloudmark-Score: 0 X-Originating-IP: 107.8.142.219 Received: from [107.8.142.219] ([107.8.142.219:60226] helo=pvr.pobox.com) by hrndva-oedge04.mail.rr.com (envelope-from ) (ecelerity 2.2.3.46 r()) with ESMTP id 05/72-04612-89FAA6D4; Sun, 27 Feb 2011 20:10:00 +0000 Received: by pvr.pobox.com (Postfix, from userid 81) id CD569CFE033; Sun, 27 Feb 2011 14:09:59 -0600 (CST) To: Subject: [gentoo-user] Re: OT: cut replacement with bash builtins X-PHP-Originating-Script: 0:func.inc Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 27 Feb 2011 14:09:59 -0600 From: hamilton In-Reply-To: <4D6AADAA.60807@binarywings.net> References: <4D6AADAA.60807@binarywings.net> Message-ID: <4d8ebcfffb7efb9fb1685df5092a61e4@mail.nethamilton.net> X-Sender: hamilton@pobox.com User-Agent: Roundcube Webmail/0.5 X-Archives-Salt: X-Archives-Hash: 23e859fca951c70362527174a3228dbf On Sun, 27 Feb 2011 21:01:46 +0100, Florian Philipp wrote: > Hi list! > > I'm currently streamlining some of my shell scripts to avoid > unnecessary > process calls where bash itself is powerful enough. My experience (take it for whatever you think it's worth) is that doing so often just makes things harder to follow and maintain. It's very unlikely that the overhead of a fork+exec is appreciably slowing your process down. Having said that (and in that vein) there is something more straightforward which may be useful: [...] > My current solution is using two string operations: > string='foo:bar:foo' > # remove everything up to and including first ':' > second_and_following=${string#*:} > # remove everything from the first ':' following > second_field=${second_and_following%%:*} second_field = $(echo $string | awk -F: '{print $2}') -- Jon Hamilton hamilton@pobox.com