bash
Martin 'Megac' Mokry
megac na vupu.sk
Čtvrtek Leden 22 08:13:26 CET 2004
On Wed, Jan 21, 2004 at 11:53:47PM +0100, Standa Pacan wrote:
> > 1. promennou zkratit o posledni znak
> lastchar()
> {
> # return the last character of a string in $rval
> if [ -z "$1" ]; then
> # empty string
> rval=""
> return
> fi
> # wc puts some space behind the output this is why we need sed:
> numofchar=`echo -n "$1" | wc -c | sed 's/ //g' `
> # now cut out the last char
> rval=`echo -n "$1" | cut -b $numofchar`
> }
V pripade ze sa nebude jednat o viacriadkove premenne, je aj
jednoduchsie riesenie:
HALUZ=`echo "$TRUBKA" |sed -e "s/\(.*\)./\1/"`
--
Martin Mokry a.k.a. Megac
Work: Network administrator @
Vyskumny Ustav Podoznalectva a Ochrany Pody
(Soil Science and Conservation Research Institute)
Bratislava, Slovakia
Další informace o konferenci Linux