Getting at the first char of a string in Bourne shell

C C Evert cevert at airgun.wg.waii.com
Tue Oct 2 06:39:55 AEST 1990


In article <1308 at ncrwat.Waterloo.NCR.COM>, ken at images1.Waterloo.NCR.COM (Ken Braithwaite) writes:
> I am trying to peel off one at a time the letters from a variable
> in the Bourne shell, ie from Bourne get B and ourne.
> How can I do this?
> Thanks in advance.
> 

expr "$SHELL" : '\(.\).*' prints the first letter of SHELL
expr "$SHELL" : '.\(.*\)' prints all but the first letter of SHELL

You still need to check for SHELL being empty.
-- 
C C Evert 
Western Geophysical - A division of Western Atlas International,
A Litton/Dresser Company           DOMAIN addr: cevert at airgun.wg.waii.com
				   UUNET address:  uunet!airgun!cevert



More information about the Comp.unix.shell mailing list