Subject: Re: Bourne shell script help
To: NetBSD Users <netbsd-users@netbsd.org>
From: Thomas Kaepernick <Thomas.Kaepernick@web.de>
List: netbsd-users
Date: 08/31/2006 22:36:58
Am Tue, Jul 25, 2006 at 12:29:31PM -0700, schrieb Andy Ruhl:
> I'm not much of a scripter, but I need to do something specific and
> I'm hoping someone can help.
> 
> This must be a /bin/sh script for portability, and I need to take 2
> characters off of a 14 or so character string and process them
> separately in order to know how to continue. If there is some common
> unix binary that does it, that would be fine, but it would be
> preferable to do it with built in function I guess. Seems like there
> is something that can easily do this, I just don't know what it is.
> 
> So it would be something like this:
> 
> string=<some 14 character alphanum string>
> 
> firstchar = "$(`cat $string | getfirstchar`)"
> secondchar = "$(`cat $string | getsecondchar`)"
> 
Excuse me I am so late. In GNU BASH you can make:

------schnipp--------
$ string="some 14 character alphanum string"
$ echo "${string:0:1}"
s
$ echo "${string:1:1}"
o
------schnapp--------

Thomas