Picking a character from a word

Root Boy Jim rbj at icst-cmr.arpa
Wed Apr 27 07:28:42 AEST 1988


   From: "Richard A. O'Keefe" <ok at quintus.uucp>

   Unfortunately, "expr substr" is a BSD-ism which has yet to find its way
   into the SVID.

Or the manual entry.

Here is yes another solution. I assume your word has no spaces in
it, or else it would be many words.

set x=abcdefghijklmnopqrstuvwxyz	# input `word'
set y=(`echo $x | sed 's/./& /g'`)	# chg each char to a word
set z=$y[17]				# select char, 1-origin indexing
echo $z					# should produce `q'

   Oh the joys of macro processors; fun till it hurts.

Yeah, but it feels so good when you stop.

	(Root Boy) Jim Cottrell	<rbj at icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
The PINK SOCKS were ORIGINALLY from 1952!!
 But they went to MARS around 1953!!



More information about the Comp.unix.questions mailing list