From: hamilton <hamilton@pobox.com>
To: <gentoo-user@lists.gentoo.org>
Subject: [gentoo-user] Re: OT: cut replacement with bash builtins
Date: Sun, 27 Feb 2011 14:09:59 -0600 [thread overview]
Message-ID: <4d8ebcfffb7efb9fb1685df5092a61e4@mail.nethamilton.net> (raw)
In-Reply-To: <4D6AADAA.60807@binarywings.net>
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
next prev parent reply other threads:[~2011-02-27 20:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-27 20:01 [gentoo-user] OT: cut replacement with bash builtins Florian Philipp
2011-02-27 20:09 ` hamilton [this message]
2011-02-27 21:50 ` [gentoo-user] " Florian Philipp
2011-02-27 21:06 ` [gentoo-user] " Alex Schuster
2011-02-27 22:08 ` Florian Philipp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4d8ebcfffb7efb9fb1685df5092a61e4@mail.nethamilton.net \
--to=hamilton@pobox.com \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox