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 1PtoXI-00069X-K8 for garchives@archives.gentoo.org; Sun, 27 Feb 2011 21:52:16 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 168231C027; Sun, 27 Feb 2011 21:50:46 +0000 (UTC) Received: from out1.smtp.messagingengine.com (out1.smtp.messagingengine.com [66.111.4.25]) by pigeon.gentoo.org (Postfix) with ESMTP id E06251C027 for ; Sun, 27 Feb 2011 21:50:45 +0000 (UTC) Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id A026320884 for ; Sun, 27 Feb 2011 16:50:45 -0500 (EST) Received: from frontend1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Sun, 27 Feb 2011 16:50:45 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:subject:references:in-reply-to:content-type; s=smtpout; bh=TJmuylxF1MssySD12S4+2Rb2+tc=; b=ZclnKDpSmRPFIhxYI+pADs6AwW+7IIma7xLEDW5xS2dJYAMKPksUX0H0Jb1aaKHF1G/rXQrVtL+u/96/vW0lEJ3cfHZcexovi+bFQsB1ghaJZg+CVdrpAKF3NCCg9El1eLP3safe9mWJY5d3xqw/+m+f8DElHmfmK3P2CGdv3qk= X-Sasl-enc: hPGOD1JHXPnYXNq4WXYyqLIS9ir8uHtPf+1NPr1xLywH 1298843444 Received: from [192.168.5.18] (lvps83-169-5-6.dedicated.hosteurope.de [83.169.5.6]) by mail.messagingengine.com (Postfix) with ESMTPSA id 4CE4D4006A4 for ; Sun, 27 Feb 2011 16:50:43 -0500 (EST) Message-ID: <4D6AC72B.4040801@binarywings.net> Date: Sun, 27 Feb 2011 22:50:35 +0100 From: Florian Philipp User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20110219 Lightning/1.0b3pre Thunderbird/3.1.7 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 To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] Re: OT: cut replacement with bash builtins References: <4D6AADAA.60807@binarywings.net> <4d8ebcfffb7efb9fb1685df5092a61e4@mail.nethamilton.net> In-Reply-To: <4d8ebcfffb7efb9fb1685df5092a61e4@mail.nethamilton.net> X-Enigmail-Version: 1.1.2 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig6FCEC248A091A88058A3E52F" X-Archives-Salt: X-Archives-Hash: c3748f8e89fa67345d5b5056fa0b1c44 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6FCEC248A091A88058A3E52F Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Am 27.02.2011 21:09, schrieb hamilton: > 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 unnecessa= ry >> process calls where bash itself is powerful enough. >=20 > 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: >=20 Oh, I completely agree with you. In 90% of all cases, simple and clean code is preferable. And if I really card about performance, I'd use C or Perl. However, there are still such rare cases where everything works fine and you see no reason to code it all again but those three forks in the innermost loop just kill your performance. In such cases, I optimize it and put the clean version in the comments. That way, clarity doesn't suffer too much. > [...] >=20 >> My current solution is using two string operations: >> string=3D'foo:bar:foo' >> # remove everything up to and including first ':' >> second_and_following=3D${string#*:} >> # remove everything from the first ':' following >> second_field=3D${second_and_following%%:*} >=20 > second_field =3D $(echo $string | awk -F: '{print $2}') >=20 >=20 Regards, Florian Philipp --------------enig6FCEC248A091A88058A3E52F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk1qxzAACgkQqs4uOUlOuU/PcwCfTnQ0Xl36/3rbwdxtCgaxxQkf sjoAnA0FwEP9mD3GwGv59id0sRd7oKTB =67wp -----END PGP SIGNATURE----- --------------enig6FCEC248A091A88058A3E52F--