RE: ** UNIX shell -- grep behavior different

  • From: A Joshi <ajoshi977@xxxxxxxxx>
  • To: jkstill@xxxxxxxxx, rajendra.pande@xxxxxxx
  • Date: Fri, 26 Nov 2010 19:17:30 -0800 (PST)

thanks Rajendra/Jared/ Waldirio/Howard
here is script part
##
. /opt/oracle/scripts/setenv
cd /opt/oracle/scripts

DBS=/opt/oracle/scripts/dbs
flist=/opt/oracle/scripts/new_obj.log
mlist=/opt/oracle/scripts/mail_new_obj.log
echo ' '> $flist
echo ' '> $mlist

cat $DBS | while read DB
do
sqlplus db_ro@$DB @new_objects.sql <.pw >> $flist
done

set -x

grep -i created $flist
grep -i created $flist > $mlist

#mailx
##

please note new_objects.sql --
select i.instance_name||' on '||
         i.host_name||' : '||d.Object_type ||' ' ||d.owner||'.'||d.object_name||
         ' created ' || d.created
from   dba_objects d, v$instance i
where d.created >sysdate - 1
and  d.Object_type not like '%BODY%'
and  d.owner not in
       ('SYS', 'SYSTEM', 'OUTLN', 'DBSNMP', 'XDB', 'TSMSYS')
order  by 1
/

all other parts working fine. I'm getting the objects created in last one day. 
From one database getting eight objects and six from another database.however 
the shell script grep finds only the eight from first database.not six from 
second database. the very same grep command when I came in my UNIX interactive 
session gets all 14.
which grep from both shell script, UNIX interactive session gives same output 
/bin/grep

+ which grep 
/bin/grep


--- On Fri, 11/26/10, rajendra.pande@xxxxxxx <rajendra.pande@xxxxxxx> wrote:

> From: rajendra.pande@xxxxxxx <rajendra.pande@xxxxxxx>
> Subject: RE: ** UNIX shell -- grep behavior different
> To: jkstill@xxxxxxxxx, ajoshi977@xxxxxxxxx
> Cc: oracle-l@xxxxxxxxxxxxx
> Date: Friday, November 26, 2010, 9:17 AM
> As always check how many versions of
> grep you have in default path vs the script path.
> If there are aliases defined
>  
> 
> -----Original Message-----
> From: oracle-l-bounce@xxxxxxxxxxxxx
> [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
> On Behalf Of Jared Still
> Sent: Friday, November 26, 2010 1:27 AM
> To: ajoshi977@xxxxxxxxx
> Cc: oracle-l@xxxxxxxxxxxxx
> Subject: Re: ** UNIX shell -- grep behavior different
> 
> Assisting with troubleshooting is much easier with a
> reproducible example.
> 
> On Thursday, November 25, 2010, A Joshi <ajoshi977@xxxxxxxxx>
> wrote:
> > hi
> >   I have a UNIX shell script that populates a
> file and then does grep on it. in the shell script it is
> missing some lines that has the grep string.
> > from interactive UNIX session grep I get bigger and
>  right list. I am using the same exact grep that is in the
> UNIX shell script. only difference is in the shell script
> file name is referred to as $flist
> > I'm submitting shell script as nohup
> > I checked everything. I tried removing the file and
> re-create.
> > it is strange. can someone help. TIA
> >
> >
> >
> >
> >
> > --
> > //www.freelists.org/webpage/oracle-l
> >
> >
> >
> 
> -- 
> Jared Still
> Certifiable Oracle DBA and Part Time Perl Evangelist
> Oracle Blog: http://jkstill.blogspot.com
> Home Page: http://jaredstill.com
> --
> //www.freelists.org/webpage/oracle-l
> 
> 
> Please visit our website at 
> http://financialservicesinc.ubs.com/wealth/E-maildisclaimer.html
> 
> for important disclosures and information about our e-mail
> 
> policies. For your protection, please do not transmit
> orders 
> or instructions by e-mail or include account numbers,
> Social 
> Security numbers, credit card numbers, passwords, or other
> 
> personal information.
> --
> //www.freelists.org/webpage/oracle-l
> 
> 
>



      
--
//www.freelists.org/webpage/oracle-l


Other related posts: