Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: Getting a particular char



From: DervishD [mailto:raul@xxxxxxxxxxxx]
Sent: 06 August 2004 11:56

>     So I'm implementing it like that:
> 
>     # Dirty and ugly hack, needs some polishing...
>     # First we get rid of all characters at the beginning
>     while [ ${#parameter} -gt n ]
>     do
>         parameter=${parameter#?}
>     done
> 
>     #   Now, get rid of the characters after
>     # the one we are interested in
> 
>     while [ ${#parameter} -gt 1 ]
>     do
>         parameter=${parameter%?}
>     done
> 
> I would like another ideas, shorter, faster, or simply less ugly,
> and it must be portable, so no zsh tricks :(( If you could please
> help me... Thanks a lot in advance.
> 

How about:

	parameter=`echo "$parameter" | cut -cn`

Sean.

_____________________________________________________________________
This message has been checked for all known viruses by Xenicom delivered through the MessageLabs Virus Control Centre. 



Messages sorted by: Reverse Date, Date, Thread, Author