Hello everyone. I'm a newbie in shell scripts. I'm trying to write a simple script that will archive a file from one directory to another directory I'm using sqlplus to generate the correct file name. The problem is when I try to use the paremeter from sqlplus it adds a space in front of it.
here is what I have:
#!/usr/bin/sh
directory=/u01/prodappl/orscgl/11.5.0/bin/
directoryNew=/u01/prodappl/orscgl/11.5.0/bin/archive/
file_name=`sqlplus -s apps/apps<<EOQ
set heading off feedback off verify off
SELECT TRIM('GLISPO'||TO_CHAR(sysdate, 'YYYYMMDD')||'.dat') FROM Dual;
exit;
EOQ
`
test=${file_name}
echo $file_name
echo $directory$file_name
echo $directoryNew$file_name
echo ${directoryNew}${test}
echo $test
I've played around trying several different ways of using ``, '', "", and {} and cannot get it to work. Here is the output I get from this.
GLISPO20061212.dat
/u01/prodappl/orscgl/11.5.0/bin/ GLISPO20061212.dat
/u01/prodappl/orscgl/11.5.0/bin/archive/ GLISPO20061212.dat
/u01/prodappl/orscgl/11.5.0/bin/archive/ GLISPO20061212.dat
GLISPO20061212.dat
Notice the spaces between the directory and the filename. This will not work with the mv command.
Thanks for the help.