Path: utzoo!mnetor!uunet!husc6!mailrus!tut.cis.ohio-state.edu!bgsuvax!kutz From: kutz@bgsuvax.UUCP (Kenneth Kutz) Newsgroups: comp.unix.questions Subject: Re: Picking a character from a word Message-ID: <1974@bgsuvax.UUCP> Date: 25 Apr 88 01:17:46 GMT References: <578@amethyst.ma.arizona.edu> Distribution: na Organization: Bowling Green State University B.G., Oh. Lines: 25 In article <578@amethyst.ma.arizona.edu>, barsam@eros.ame.arizona.edu (Barsam Marasli) writes: > 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. Use 'cut' if you have it. [echo "stuff" | cut -c3] --> outputs 'u' similarly [echo "stuff" | cut -c1] --> outputs 's' -- -------------------------------------------------------------------- Kenneth J. Kutz CSNET kutz@bgsu.edu UUCP ...!osu-cis!bgsuvax!kutz Disclaimer: Opinions expressed are my own and not of my employer's --------------------------------------------------------------------