Ref. http://go-linux.blogspot.tw/2007/03/basharray.html
#!/bin/bash
#Put everything into array.
array=(Redhat Novell MicroSoft Sun IBM HP Dell)
#Print all value in array , seperated by IFS(:).
IFS=:
echo "${array[*]}"
#Print all value in array , seperated by IFS(\n).
IFS=$'\n'
echo "${array[*]}"
#Print all value in array , seperated.
echo "${array[@]}"
#Print the count of array.
echo "${#array[@]}"
Re:
array[0]=Redhat
array[1]=Novell
array[2]=MicroSoft
array[3]=Sun
array[4]=IBM
array[5]=HP
array[6]=Dell
Redhat:Novell:MicroSoft:Sun:IBM:HP:Dell
Redhat
Novell
MicroSoft
Sun
IBM
HP
Dell
Redhat Novell MicroSoft Sun IBM HP Dell
7
#Put everything into array.
array=(Redhat Novell MicroSoft Sun IBM HP Dell)
#Print all value in array , seperated by IFS(:).
IFS=:
echo "${array[*]}"
#Print all value in array , seperated by IFS(\n).
IFS=$'\n'
echo "${array[*]}"
#Print all value in array , seperated.
echo "${array[@]}"
#Print the count of array.
echo "${#array[@]}"
Re:
array[0]=Redhat
array[1]=Novell
array[2]=MicroSoft
array[3]=Sun
array[4]=IBM
array[5]=HP
array[6]=Dell
Redhat:Novell:MicroSoft:Sun:IBM:HP:Dell
Redhat
Novell
MicroSoft
Sun
IBM
HP
Dell
Redhat Novell MicroSoft Sun IBM HP Dell
7
No comments:
Post a Comment