Friday, August 19, 2005

 

AskTom "Why is it said that global indexes are s..."

AskTom "Why is it said that global indexes are s..."

 

Oracle 8 Partitions

Oracle 8 Partitions

 

保持 Oracle 数据库优良性能

保持 Oracle 数据库优良性能

 

Linux伊甸园论坛 - 如何保持Oracle数据库的优良性能


Thursday, August 18, 2005

 

Oracle-SAP Technology Update Letter, Vol. 2

Oracle-SAP Technology Update Letter, Vol. 2

 

LinuxAid 技术支持中心

LinuxAid 技术支持中心

 

历史上最强的sql FAQ for Oracle

历史上最强的sql FAQ for Oracle

 

linux知识宝库/oracle/oracle8的ROWID结构


Tuesday, August 16, 2005

 

ZDNet Asia : Testing Web links with LinkChecker for Linux

Your friend would like you to read the article entitled:
Testing Web links with LinkChecker for Linux

which can be found at http://www.zdnetasia.com/techguide/opensource/0,39044899,39246526,00.htm

This is a free user service of ZDNet Asia (http://www.zdnetasia.com)
Check out ZDNet Asia today!

Latest technology news: http://www.zdnetasia.com/news
Insight: http://www.zdnetasia.com/insight
Developers: http://www.zdnetasia.com/builder
SMB: http://www.zdnetasia.com/smb
Downloads: http://www.zdnetasia.com/downloads


 

Using arrays in bash

By Vincent Danen, TechRepublic
Assigning variables in bash is easily done and extremely useful, but like other programming languages, bash can also use arrays. This is particularly handy when you want to read the contents of a file into an array or simply keep your scripts more organized and logical.
There are two ways of declaring an array:


declare -a FOO

This creates an empty array called FOO. You can also declare an array by assigning values to it:


FOO[2] = 'bar'

This assigns the third element of the array to the value 'bar'. In this instance, FOO[0] and FOO[1] are also created, but their values are empty.

To populate an array, use:


FOO=( bar string 'some text' )

This assigns the first element (FOO[0]) to 'bar', the second (FOO[1]) to 'string' and the final element (FOO[3]) to 'some text'. Notice that the array elements are separated by a blank space, so if a value contains white spaces it must be quoted.

To use an array, it is referred to as $FOO[2] but it also needs to be surrounded in curly braces, otherwise bash will not expand it correctly:


$ echo {$FOO[2]}
some text

To loop through an array, you can use a piece of shell code like the following:


#!/bin/sh

FOO=( bar string 'some text')
foonum=${#FOO}

for ((i=0;i<$foonum;i++)); do
echo ${FOO[${i}]}

done


Here we loop through each item of the array and print out its value. Each array element is accessed by number, so we use the special variable ${#FOO} which gives the number of elements in the array (in the above case, it would return the number 3). That value is then used in the for loop to determine how many times to loop. By accessing the array in this manner, you can easily generate arrays from external data or command-line arguments, and process each element one at a time.

This page is powered by Blogger. Isn't yours?