bash - Echo out a variable like cat in a string -
bash - Echo out a variable like cat in a string -
i have sql statement results in little table of values. have @ every day can compare yesterdays. sick of doing this.
/big/database/v10.2.0.2.0-32bit/bin/sqlplus -s casper/secret@wowmomdb2 @/home/casper/installed.sql
so made little script.
#!/bin/bash set -x dayofweek=$(/bin/date +%w) today=$(/bin/date +%y%m%d) if [ $dayofweek == 1 ] ; yesterday=$(/bin/date -d "3 days ago" +%y%m%d) else yesterday=$(/bin/date -d "1 day ago" +%y%m%d) fi invoke="/big/database/v10.2.0.2.0-32bit/bin/sqlplus -s " login="casper/secret@wowmomdb2 " filter="@/home/casper/installed.sql" installed="/home/casper/_symbols" table="$invoke $login $filter" $table > $installed.$today echo "installed today -------- $installed.$today installed yesterday -------- $installed.$yesterday " | mail service -s "diff exchange installed" casper@big_bank.com #/big/database/v10.2.0.2.0-32bit/bin/sqlplus -s casper/secret@wowmomdb2 @/home/casper/installed.sql > /tmp/check_c4_exchange.$today
problem want mailed me.
installed today-------- /home/casper/_symbols.20141104 installed yesterday---- /home/casper/_symbols.20141105
what want todays , yesterdays little table printed out , emailed me can @ in morning. want tables catted out. _ don't want utilize kinds of echos - know echo out each line. ~
the problem $installed.$today
name of file. want contents of file. try:
echo "installed today -------- $(cat $installed.$today) installed yesterday -------- $(cat $installed.$yesterday) "
more efficient alternative if using bash
, not necessary utilize cat
:
echo "installed today -------- $(<$installed.$today) installed yesterday -------- $(<$installed.$yesterday) "
this approach avoids need spawn subshells in run cat
, making more efficient.
bash
Comments
Post a Comment