Re: Extracting a character from a string
- From: Stephan Grein <stephan@xxxxxxxxxxxxxxxx>
- Date: Wed, 20 Dec 2006 13:30:48 +0100
Stu wrote:
Im looking for a way to get a character from a string using KSH. For
example, in perl code I can do this:
my($first_char) = substr($string, 0, 1); # Get the first
character from the string
my($second_char) = substr($string, 1, 1); # Get the second
character from the string.
Is there something similiar I can do in kSH.
I don't know if this is a bashism but maybe you try:
fubar="foo bar"
echo ${fubar:1:1}
yield "f"
Thanks in advance to all who answer this post
HTH,
--
Stephan Grein, <stephan at stephan minus rockt dot de>
https://stephan-rockt.de
GnuPG-Key-ID: 0xF8C275D4
FingerPrint: 5B6F 134A 189B A24D 342B 0961 8D4B 0230 F8C2 75D4
.
- Follow-Ups:
- Re: Extracting a character from a string
- From: Janis Papanagnou
- Re: Extracting a character from a string
- References:
- Extracting a character from a string
- From: Stu
- Extracting a character from a string
- Prev by Date: Re: Extracting a character from a string
- Next by Date: Re: Extracting a character from a string
- Previous by thread: Re: Extracting a character from a string
- Next by thread: Re: Extracting a character from a string
- Index(es):
Relevant Pages
|