[Nelug] Bash Scripting

Andrew Hatch andrew.hatch at bluespace.com
Fri Sep 19 11:04:01 UTC 2003


Wonder if anybody has come across the following:

-----------------------------------
#!/bin/bash

NUMFILES=3
FILE1="/home/file1.dat"
FILE2="/home/file2.dat"
FILE3="/home/file3.dat"

for i in $(seq $NUMFILES)
do
        THEFILE=FILE$i
        echo $THEFILE
done
------------------------------------

this will output the following:

FILE1
FILE2
FILE3

But what I want it to do is output

/home/file1.dat
/home/file2.dat
/home/file3.dat

How can I force bash to 'dereference' $FILE1 to be "/home/file1.dat"?

Any help would be much appreciated.

Cheers,
Andrew




More information about the Nelug mailing list