home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1999 October
/
PCWorld_1999-10_cd1.bin
/
Hardware
/
Drivers
/
ZoomShel
/
zoom.exe
/
variable_fun.zsh
< prev
next >
Wrap
Text File
|
1999-02-07
|
2KB
|
51 lines
echo
echo
##########################################
# Some fun with variables, showing the
# Zoom Shell implementation of Posix
# variable syntax, with Zoom Shell extensions
# thrown in as well.
##########################################
Test=SuperCalaFragalistic Expialadocious
echo Our word for today is: ${Test}
##########################################
# length
##########################################
LenTest=${#Test}
echo The length of our word is: $LenTest characters.
##########################################
# items in an "array"
##########################################
ItemCount=${#Test[*]}
echo The number of items in this string is: $ItemCount
echo The first item is: ${Test[1]}
echo The last item is: ${Test[$ItemCount ]}
##########################################
# substitute in missing variables
##########################################
echo "test_null" has been set to ${test_null}
echo "test_null" has been set to ${test_null:=nothing at all}
echo "Test" has been set to ${Test:=Empty String}
##########################################
# chop off the left side
##########################################
Left=Super
echo The part after "${Left}" is: ${Test#${Left}}
##########################################
# chop off the right side
##########################################
Right=ious
echo The part before "${Right}" is: ${Test%${Right}}
##########################################
# substring function
##########################################
echo Some characters from the middle: ${Test,8,10}
echo From the twelth character onward: ${Test,12}
echo This should equal the previous line: ${Test,12,${LenTest}}