May 15, 2011

While loop in bash

# remove the last line
function ProcessDistFile {

# Overwrite the file with nothing.
# echo -n > $1

# Write the lines in reverse order
let startFrom=$2-1
if [[ $startFrom -ge 0 ]]
then
while [ $startFrom -ge 0 ]
do
# echo ${lines[$j]} >> $1 # the array is accessible since global. Does not need to be passed
echo "Element is ${lines[$startFrom]}"
startFrom=$[$startFrom-1]
done
fi


}

While Loop Reference

No comments:

Carlo Cipolla's Laws of Stupidity

    "By creating a graph of Cipolla's two factors, we obtain four groups of people. Helpless people contribute to society but are...