Picking a character from a word

Barsam Marasli barsam at eros.ame.arizona.edu
Sat Apr 23 07:02:36 AEST 1988


I have a csh question.
I would like to have a script that will echo, say the 4th character
of an arguement. I came up with the following:

set word=`echo $1 | od -c` ; echo $word[5]

which seems to do the job but somehow I feel like there are
more elegant ways of doing this. Please reply by e-mail or
post. Also what's an alternative in sh? Thanx.

------------------------------------------------------------------------
Barsam Marasli
Internet: eros!barsam at arizona.edu
UUCP    : ...{allegra,ihnp4,cmcl2,hao!noao}!arizona!eros!barsam
Bitnet  : barsam at arizrvax
------------------------------------------------------------------------
Barsam Marasli                  # Speak slowly, I hear with an accent. #
Internet: eros!barsam at arizona.edu
UUCP    : ...{allegra,ihnp4,cmcl2,hao!noao}!arizona!eros!barsam
Bitnet  : barsam at arizrvax



More information about the Comp.unix.questions mailing list