RE: ** UNIX shell -- grep behavior different

From: A Joshi <ajoshi977_at_yahoo.com>
Date: Fri, 26 Nov 2010 19:17:30 -0800 (PST)
Message-ID: <378294.14777.qm_at_web57515.mail.re1.yahoo.com>



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_at_$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_at_ubs.com <rajendra.pande_at_ubs.com> wrote:
> From: rajendra.pande_at_ubs.com <rajendra.pande_at_ubs.com>
> Subject: RE: ** UNIX shell -- grep behavior different
> To: jkstill_at_gmail.com, ajoshi977_at_yahoo.com
> Cc: oracle-l_at_freelists.org
> 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_at_freelists.org
> [mailto:oracle-l-bounce_at_freelists.org]
> On Behalf Of Jared Still
> Sent: Friday, November 26, 2010 1:27 AM
> To: ajoshi977_at_yahoo.com
> Cc: oracle-l_at_freelists.org
> 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_at_yahoo.com>
> 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
> >
> >
> >
> >
> >
> > --
> > http://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
> --
> http://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.
> --
> http://www.freelists.org/webpage/oracle-l
> 
> 
>



      
--
http://www.freelists.org/webpage/oracle-l
Received on Fri Nov 26 2010 - 21:17:30 CST

Original text of this message