[ale] String editing using the shell (/bin/sh)

Geof esoteric at denali.atlnet.com
Thu Nov 30 16:00:40 EST 2000


Kenneth W Cochran wrote:
> 
> Hi,
> 
> I'm trying to rename files using shell scripting (/bin/sh).
> How do I "edit" the "name?"
> 
> As examples, I'd like to be able to do:
> 1.  a "prefix substitution"  (Is there a shell feature that
>     will allow this?)  I can do a "prefix chop" using
>     ${p#w}, but how about a substitution?

I don't know that you can do a substitution, but using the ${p#w}
approach you can chop off the prefix and prepend what you what there
like 'foo=not-bar${foo#bar}'

> 2.  an "in the middle" substitution  (sed?)

You'll probably end up using a combination of
${p#w}put-something-here${p%w}

> 3.  a "suffix substitution"  (same as #1, but on the
>     "other" end)  I can do a "suffix chop" using ${p%w},
>     but, as in (1.) how might I do a substitute?

Review answer to #1 in a mirror... :)

> 
> Btw, any good shell programming book references?  My 1990
> Kochan & Wood 2nd ed seems rather old nowadays... :)

I still use my old ksh book, but that's because I use, uh, ksh. :)

> 
> Thanks,
> 
> -kc
> --
> To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.

--
Until later: Geoffrey		esoteric at denali.atlnet.com

"Great spirits have always found violent opposition from mediocre minds.
The
latter cannot understand it when a man does not thoughtlessly submit to
hereditary prejudices but honestly and courageously uses his
intelligence."
- Albert Einstein
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list