Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.shell Subject: Re: Getting at the first char of a string in Bourne shell Message-ID: <9737@jpl-devvax.JPL.NASA.GOV> Date: 28 Sep 90 23:59:11 GMT References: <1308@ncrwat.Waterloo.NCR.COM> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 23 In article <1308@ncrwat.Waterloo.NCR.COM> ken@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? A fairly efficient way would be echo "Bourne" | SOMETHING | while read line; do ... done where SOMETHING is one of sed 's/\(.\)/\1\ /g s/\n$//' perl -pe 'chop; s/./$&\n/g' There are lots of other ways. Larry Wall lwall@jpl-devvax.jpl.nasa.gov