HP3000-L Archives

August 2003, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Ken Hirsch <[log in to unmask]>
Reply To:
Ken Hirsch <[log in to unmask]>
Date:
Thu, 7 Aug 2003 14:32:27 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (42 lines)
String handling in the shell, per se, is actually pretty poor.  On a real
Unix system, it's pretty fast do use awk/sed/Perl to do string processing,
e.g.
b=$(echo a | awk '{ some string stuff}').  Under MPE, it's pretty slow to do
this.  I usually write in Perl.

But here's how you can do this in the shell:

_input_string="key:val"
_field_name=${_input_string%:*}
_field_value=${_input_string#*:}

----- Original Message -----
From: "John Burke" <[log in to unmask]>
To: <[log in to unmask]>
Sent: Thursday, August 07, 2003 12:22 PM
Subject: [HP3000-L] Shell script help


> I'm very much a newbie to shell scripting. I'm trying to convert a CI
> command script to a shell script. I've successfully gotten all the
> boilerplate stuff converted but have a few simple questions (simple for
> shell script mavens). My first question concerns converting the following
CI
> commands:
>
>   setvar _field_name word(_input_string, ":", 1)
>   setvar _field_value word(_input_string, ":", 2)
>
> Basically I'm parsing a character string into two pieces where ":" is the
> delimiter (always present) and the second part could be null (the first
part
> never is null). How do I do this in a shell script?
>
> John
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2