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
hamil...@pobox.com

Reply via email to