HP3000-L Archives

September 2002, Week 3

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:
Jeff Woods <[log in to unmask]>
Reply To:
Date:
Thu, 19 Sep 2002 13:49:08 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
Paul Christidis asked:
>Given the following:
>OPT="d=#paulc f=STAGE t=Staging Area flist='/usr/tmp/paulc_34433:4656'"
>
>Could someone suggest the magic words (sed, cut, etc..) that 
>would remove
>everything AFTER the word "Area ".
>
>The 'key' string is " flist='"

If you are using KSH, BASH or MPE's POSIX shell, and OPT is a shell
variable that does not have the [double] quotation marks (") in it you
can drop the "flist=" and everything after that using ${OPT%flist=*} to
dereference the variable.  If you also want to drop the blank before it
(and know it will always be present) you would use ${OPT% flist=*}

Inside a shell variable reference ${OPT} you may use any of several
operators to modify the results; these include % and # which delete a
pattern from the right or left respectively of the result.  Double %%
and ## delete as much as possible whereas the single % and # versions
delete as little as possible.  Examples:

${SomePath}             -> a/b/c/d/e
${SomePath#*/}  -> b/c/d/e
${SomePath#*/c} -> /d/e
${SomePath##*/} -> e
${SomePath##*/c}        -> /d/e
${SomePath%/*}  -> a/b/c/d
${SomePath%c/*} -> a/b/
${SomePath%%/*} -> a
${SomePath%%c/*}        -> a/b/

If you can't use "flist" as your key but want to use "Area" and still
leave "Area" in the result, you can use "${OPT%Area *}Area".
--
Jeff Woods
[log in to unmask]
[log in to unmask]
Quintessential School Systems

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

ATOM RSS1 RSS2