Dynamic file name in variable

Hi guys.

i have a requirment as below.

I have a scripts which perform for loop

for i in /backup/logs -- it will give all the logs file
SC_RIO_RWVM_20120413064217303.LOG
SC_RIO_RWXM_20120413064225493.LOG
SC_RIO_RXXM_20120413064233273.LOG
...

do
open script.sh ---- in this file i have a variable which well be set as the above file name .

eg. when SC_RIO_RXXM_20120413064233273.LOG is getting process

then
in the called scripts the variable values should be set as
v_file name = SC_RIO_RXXM_20120413064233273.LOG.

when loop go into another file
SC_RIO_RXXM_20120413064233273.LOG

then
in the called scripts the variable values should be set as
v_file name = SC_RIO_RXXM_20120413064233273.LOG.

this means that the variable will accept the file name dynamically upon called scripts in the for loop.

Any help will save my work a lot, i am stuck with this logic.

Thanks

Rajesh

pass log file name to your script and assign that name to you script:

open script.sh $i

in your script assign variable as

v_file name=$1

Ok Fine,

Actually the file which will be called "scripts.sh" contains sql loader control file structure.
i don't know if i can add into it anything which additional to control file information.

Can you please reply if you know this

---------- Post updated at 11:04 AM ---------- Previous update was at 10:56 AM ----------

Hi can we modify the file contain while processing and close befor next lines get execute.

my control file has below text

load data
        BADFILE /backup/temp/rajesh/BadFiles/rio.bad
        append into TEMP_rio_RESP_TIME_LND
        (
        INSTALLATION_ID          CHAR
        TERMINATED BY "," ENCLOSED BY '"',
        TRANSACTION_ID           CHAR
        TERMINATED BY "," ENCLOSED BY '"',
         file_name)

----this file name should be set every time new file is getting processed.

so the code should be

for i in /backup/logs -- it will give all the logs file
SC_RIO_RWVM_20120413064217303.LOG
SC_RIO_RWXM_20120413064225493.LOG
SC_RIO_RXXM_20120413064233273.LOG

do

open ctl file and set the file name.
open scripts.sh --- which has referenced to ctl file just set above.

Thanks for understanding

so basically you need to alter your control file.

try this

sed -i s:file_name:${i}:g controlfile
open script.sh