🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1304

Re: Getting at the first char of a string in Bourne shell

#1304
From: Leslie Mikesell
Date: Tue, 02 Oct 1990 03:34
24 lines
988 bytes
In article <1990Sep29.215559.25098@cti-software.nl> pim@cti-software.nl (Pim Zandbergen) writes:
>How about 

>string=`echo $string | cut -c1`

>I don't think the Bourne shell can do this without executing
>an external command.

There's always something like:

string=foo
for i in a b c d e f g (you know the rest...)
do
case "$string"
 in
$i*) first=$i
 break
 ;;
esac
done
echo $first

Les Mikesell
  les@chinet.chi.il.us
Technical Details
Message-ID: <1990Oct02.033407.5415@chinet.chi.il.us>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!orc!inews!iwarp.intel.com!gargoyle!chinet!les
References: <9737@jpl-devvax.JPL.NASA.GOV> <1990Sep29.193617.25752@iwarp.intel.com> <1990Sep29.215559.25098@cti-software.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!orc!inews!iwarp.intel.com!gargoyle!chinet!les
From: les@chinet.chi.il.us (Leslie Mikesell)
Newsgroups: comp.unix.shell
Subject: Re: Getting at the first char of a string in Bourne shell
Message-ID: <1990Oct02.033407.5415@chinet.chi.il.us>
Date: 2 Oct 90 03:34:07 GMT
References: <9737@jpl-devvax.JPL.NASA.GOV> <1990Sep29.193617.25752@iwarp.intel.com> <1990Sep29.215559.25098@cti-software.nl>
Organization: Chinet - Chicago Public Access UNIX
Lines: 24