
July 10th, 2007, 04:22 AM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 14
Time spent in forums: 4 h 35 m 57 sec
Reputation Power: 0
|
|
|
*** GOT IT!!! ***
Well..., at least it works on Cygwin. Later today I'll check it out at work on SunOS using bash, and on Centos 4.4 also using bash.
Yea me!
*********************************************
# get the number of lines in the file
numLines=(`wc -l 18sites.txt | sed 's/ 18sites.txt//'`)
# load the file into an array, hack off newlines and replace with whitespace
array=(`cat 18sites.txt | tr '\n' ' '`)
# because of array zero indexing, decrement the counter by one
counter=`expr $numLines - 1`
# print out every 3rd line from the array
for ((i = 0 ; i <= $counter ; i++))
do
# adjust for zero indexing
tmp=`expr $i + 1`
# calculate the remainder from mod division
remainder=`expr $tmp % 3`
# test for a remainder of zero, print the value if the test is met
if (test $remainder -eq 0 -a $i -gt 0)
then
echo ${array[$i]}
fi
done
|