How to grep filenames from a file in other files?

Hi,

We have a file called applcust.txt where we keep records of our customizations in the following format. We want to verify whether the file, which is in 3rd column in this file is there in another file called patch999999.log to find out if any of our customization has got overwritten by the patch. In this file, all the lines which begin with # is a comment, which needs to be ignored. From the remaining lines, we need to take the 3rd column and grep that into patch999999.log.

Could you please help me write the script/command for this?

Thanks in Advance,

Sam

%%% applcust file format 11.5.A
# +=======================================================================+
# |    copyright (c) 1995 oracle corporation redwood shores, ca usa       |
# |                         ALL rights reserved.                          |
# +=======================================================================+
# | filename                                                              |
# |  applcust.txt                                                         |
# |                                                                       |
# | $header: applcust.txt 115.1 99/07/17 04:36:28 porting ship $          |
# |                                                                       |
# | description                                                           |
# |                                                                       |
# | oracle applications customized files registration FILE.               |
# |                                                                       |
# | notes                                                                 |
# |                                                                       |
# | you should LIST ALL oracle applications files that you have           |
# | customized IN this FILE.                                              |
#=====================================================
#
# SAMPLE entries (commented OUT)
#

# --------------------------------------------------------------------------
# sprd  src dir    src fname  dprd  dest dir  dest fname
# --------------------------------------------------------------------------

# fnd  bin    found45  # considered cbm because NO destination listed
# fnd  bin    found45    fnd  bin    found45  # cbm
# fnd  bin    startmgr  xxfnd  bin    startmgr # cbe
# fnd  lib    xitiap.o  xxfnd  lib    xitiap.o # cbe
# fnd  lib/libfnd.A  xitdgl.o # considered cbm because NO destination listed
# fnd  lib/libfnd.A  xitdgl.o  fnd  lib/libfnd.A  xitdgl.o # cbm
# fnd  lib/libfnd.A  xitdgl.o  xxfnd  lib/libxxfnd.A  xitdgl.o # cbe

# ar  forms/us  arxsuvat.fmb  xxar  forms/us  arxsuvat.fmb

# ap  reports    apxachec.rdf  xxap  reports    apxachec.rdf

#
# REAL entries
#
ap      reports/US           apxachec.rdf          xxap    reports/US apxachec.rdf
pay     reports/US           payuscda.rdf          pay     reports/US payuscda.rdf
pay     patch/115/sql        pychqwrt.pkb        xxcper admin/sql  xxh_hr_pychqwrt.pkb
#  Added hxtotcri.pkb on 02/02/2010 
hxt     patch/115/sql        hxtotcri.pkb          xxcper  admin/sql  xxh_hxt_otc_retrieval_int_pkg.pkb
po      patch/115/sql        POXWPAMB.pls

#
# END OF oracle applications customized files registration FILE
#
awk '!/^#|^$/{print $3}' applcust.txt  | while read i ; do grep $i patch999999.log >/dev/null 2>&1 || echo "$i not found in log" ; done
1 Like

Thanks Funsken.

I am trying to write a script using your code as below but it is not working.

awk '!/^#|^$/{print $3}' $APPL_TOP/admin/applcust.txt > /opt/sysdba/bin/custfile.txt
fname=/opt/sysdba/bin/custfile.txt
read fname
while read line
do
  echo $line
  l=$line
  patch_text=`grep $l $APPL_TOP/admin/ohfdv2/log/u9062727.lgi`
  echo $patch_text
done

Could you please help?

Thanks,

Sam

---------- Post updated at 03:07 PM ---------- Previous update was at 01:31 PM ----------

OK, found it.

for i in `awk '!/^#|^$/{print $3}' $APPL_TOP/admin/applcust.txt`
do
  echo $i
  patch_text=`grep $i $APPL_TOP/admin/ohfdv2/log/u9062727.lgi|grep Copying`
done

Thanks again!

  • Sam