Here is a simple script to concat file names to make a list of table to be created.
tabnames.bash
#!/bin/bash
ADDITIONALTABLES="FXRATES ANVIL"
ls /abc/static/rtce_reports/static/*.csv | while read staticFile
do
staticTable=`basename $staticFile`
echo $staticTable
ADDITIONALTABLES=$ADDITIONALTABLES" "${staticTable%.csv}
echo $ADDITIONALTABLES
done
echo $ADDITIONALTABLES
the file are:
$ ls /abc/static/rtce_reports/static/*.csv
/abc/static/authority.csv
/abc/static/creditRating.csv
/abc/static/creditdept.csv
/abc/static/currency.csv
/abc/static/organiationType.csv
/abc/static/sector.csv
below is the output:
$ ./tabnames.bash
authority.csv
FXRATES ANVIL authority
creditRating.csv
FXRATES ANVIL authority creditRating
creditdept.csv
FXRATES ANVIL authority creditRating creditdept
currency.csv
FXRATES ANVIL authority creditRating creditdept currency
organiationType.csv
FXRATES ANVIL authority creditRating creditdept currency organiationType
sector.csv
FXRATES ANVIL authority creditRating creditdept currency organiationType sector
FXRATES ANVIL
as soon as it goes out of loop, the value of ADDITIONALTABLES is reset to its value it held before entering the loop.
Why?