Visit The New, Modern Unix Linux Community

How to grep filenames from a file in other files?

Thread Tools Search this Thread
Operating Systems AIX How to grep filenames from a file in other files?
# 1  
How to grep filenames from a file in other files?


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,


%%% 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

Moderator's Comments:
Mod Comment Use code tags, please...

Last edited by Scott; 07-13-2010 at 12:56 PM.. Reason: Code tags
# 2  
awk '!/^#|^$/{print $3}' applcust.txt  | while read i ; do grep $i patch999999.log >/dev/null 2>&1 || echo "$i not found in log" ; done

This User Gave Thanks to funksen For This Post:
# 3  
Originally Posted by funksen
awk '!/^#|^$/{print $3}' applcust.txt  | while read i ; do grep $i patch999999.log >/dev/null 2>&1 || echo "$i not found in log" ; done

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
read fname
while read line
  echo $line
  patch_text=`grep $l $APPL_TOP/admin/ohfdv2/log/u9062727.lgi`
  echo $patch_text

Could you please help?



---------- 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`
  echo $i
  patch_text=`grep $i $APPL_TOP/admin/ohfdv2/log/u9062727.lgi|grep Copying`

Thanks again!

- Sam

Moderator's Comments:
Mod Comment Perhaps the last one was not clear enough Use code tags, please...

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #116
Difficulty: Easy
Linux distributions are the most famous and healthiest example of the Unix derivatives; but macOS is currently the largest installed Unix user base (2019).
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I custom sort the files in a directory using the filenames in a text file.?

Hi all, (5 Replies)
Discussion started by: KMusunuru
5 Replies

2. Shell Programming and Scripting

There are multiple filenames in the directory.How to return the the lastest files for each file name

there are mutiple file nams in the directory. How to return the the lastest files for each file name. ex. abc1234_050201 abc1234_050206 abc1234_050208 xyz34_050204 xyz34_050210 xyz34_050218 thanks (4 Replies)
Discussion started by: grand_sam
4 Replies

3. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies

4. Shell Programming and Scripting

Perl - grep issue in filenames with wildcards

Hi I have 2 directories t1 and t2 with some files in it. I have to see whether the files present in t1 is also there in t2 or not. Currently, both the directories contain the same files as shown below: $ABC.TXT def.txt Now, when I run the below script, it tells def.txt is found,... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

5. UNIX for Dummies Questions & Answers

Help with grep - not showing filenames

Hello, I'm looking for a search string within about 50 files but when the string is found it doesn't tell me in which member it has been found. Any ideas how I can do this? Cheers Rob (4 Replies)
Discussion started by: Grueben
4 Replies

6. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

7. Shell Programming and Scripting

read list of filenames from text file and remove these files in multiple directories

I have a large list of filenames from an Excel sheet, which I then translate into a simple text file. I'd like to use this list, which contains various file extensions , to archive these files and then remove them recursively through multiple directories and subdirectories. So far, it looks like... (5 Replies)
Discussion started by: fxvisions
5 Replies

8. UNIX for Dummies Questions & Answers

how to grep filenames and sizes?

How to grep names and sizes of files in a directory by month and output to a file? ex: file1 | size1 file2 | size2 ... ... so on (2 Replies)
Discussion started by: helen008
2 Replies

9. Shell Programming and Scripting

Getting a list of filenames of moved files

I'm moving a list of files of some extension and I wish to output the moved filenames into a text file, I tried using the command below, but after all the files are moved, I got a blank file. find /abc/temp -type f -mtime +365 \( -name "*.bak" -o -name "*.log" \) -exec mv -f {} /junk \; >>... (3 Replies)
Discussion started by: chengwei
3 Replies

10. Shell Programming and Scripting

how to grep all the filenames in a script

hello, we have a script (let say ABC) which contains the below: lp -d lp06 -t 'REPORT FOR FINANCE -FIN-' $daily/FINRPT lp -d lp06 -t 'REPORT FOR FINANCE -FIN1-' $daily/FINRPT1 lp -d lp06 -t 'REPORT FOR HUMAN RESOURCE -HR-' $dd_daily/HRRPT lp -d lp06 -t 'REPORT FOR MANAGEMENT -MGM-'... (10 Replies)
Discussion started by: newbie168
10 Replies

Featured Tech Videos