Can any one help me out how to remove space from below line
select file_name from dba_data_files where tablespace_name='SYSTEM ----space---- ';
i want as :
select file_name from dba_data_files where tablespace_name='SYSTEM';
my code i use
file=/u01/script/latest/tbs.temp
while IFS= read -r LINE; do
echo "select file_name from dba_data_files where tablespace_name='$LINE';" >> /u01/script/latest/tbs.sql
done < "$file"
cd /u01/script/latest/
rm -rf check_tablespace.temp datafiles.log sql.log tbs.sql tbs.temp
sqlplus -s / as sysdba << eof > /u01/script/latest/check_tablespace.temp
set pages 0
Select a.tablespace_name,sum(a.tots/1048576) Tot_Size,
sum(a.sumb/1024) Tot_Free, sum(a.sumb)*100/sum(a.tots) Pct_Free,
ceil((((sum(a.tots) * 15) - (sum(a.sumb)*100))/85 )/1048576) Min_Add
from (select tablespace_name,0 tots,sum(bytes) sumb
from dba_free_space a
group by tablespace_name
union
Select tablespace_name,sum(bytes) tots,0 from
dba_data_files
group by tablespace_name) a
group by a.tablespace_name
having sum(a.sumb)*100/sum(a.tots) < 10
order by pct_free;
exit
eof
cd /u01/script/latest/
chmod ugo+rw /u01/script/latest/check_tablespace.temp
counter=`cat check_tablespace.temp | sed '/^$/d'| wc -l`
echo "count="$counter
#imaintbs=`awk '{print $1}' check_tablespace.temp`
maintbs=$(cat /u01/script/latest/check_tablespace.temp | cut -d' ' -f1 | sed '/^\s*$/d' >>/u01/script/latest/tbs.temp)
#echo $maintbs >> /u01/script/latest/tbs.temp
echo $maintbs
echo "THESE ARE THE SQL FILES PRESENT IN THE GIVEN PATCH:"
var1=$1
echo "Do You Want To APPLY Sql FILE????"
RESPONSE1=1
while :
do
read RESPONSE
if [ "$RESPONSE" == "YES" -o "$RESPONSE" == "yes" ]
then
file=/u01/script/latest/tbs.temp
while IFS= read -r LINE; do
#echo "select file_name from dba_data_files where tablespace_name='$LINE';" >> /u01/script/latest/tbs.sql
echo "select file_name from dba_data_files where tablespace_name = ${LINE%%};" >> /u01/script/latest/tbs.sql
done < "$file"
sqlplus -s / as sysdba << eof > /u01/script/latest/datafiles.log
@/u01/script/latest/tbs.sql
eof
exit
rm -rf /u01/script/latest/tbs.temp
rm -rf /u01/script/latest/tbs.sql
exit
RESPONSE=$?
echo "SQL DEPLOYMENT COMPLETED"
elif [ "$RESPONSE" == "NO" -o "$RESPONSE" == "no" ]
then
echo "sql not applied"
exit
RESPONSE1=$?
else
echo "Please Enter correct choice"
fi
if [ $RESPONSE1 -eq 0 ]
then
break
fi
done
select file_name from dba_data_files where tablespace_name = 'SYSTEM^I^I^I^I';$
select file_name from dba_data_files where tablespace_name = 'SYSAUX^I^I^I^I';$