I need to pass a variable to a Perl statement from a bash script through sqlplus, to edit a file. It works fine without passing the count variable but encounters a problem when passing it.
count=$( sqlplus -s test/test <<-EOF
set pagesize 0;
set feedback off;
set verify off;
set heading off echo off;
select count(*) from test;
exit;
EOF)
if [ "$count" != "" ] && [ $count != "0" ]; then
perl -lpe 'print "Total Number of Rejected Files = "$count"" if $. == 10' Results.txt >> data.txt
else
fi
As far as I know, my problem only with this part "$count". I have tried a lot of things like :
perl -lpe 'print "Total Number of Rejected Files = $ENV{'count'}" if $. == 10' Results.txt >> data.txt
and this :
perl -lpe 'print "Total Number of Rejected Files = $ENV{count}" if $. == 10' Results.txt >> data.txt
but the problem is that the bash variable does not expand through the perl statement.
Results.txtbut you don't seem to declare or use that anywhere