Take a list if strings from a file and search them in a list of files and report them


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Take a list if strings from a file and search them in a list of files and report them
# 8  
Old 07-31-2011
But this doesn't check the 19th field!!
# 9  
Old 10-13-2011
Question Similarly...

I'm trying to achieve similar thing but in diff way Smilie

https://www.unix.com/shell-programmin...#post302564207

That is, I've a string to grep from a series of files, when it finds the string, it should redirect the srting+from which file it got that string! Smilie

I'd tried using the above posted command, however I'm getting the below

Code:
> bash -x pleasework.sh
+ logpath=/opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging
++ date +%Y%m%d
+ awk 'NR==FNR{a[$0]=1}$1 in a{print FILENAME":"$0}' 2.txt /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler0.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler1.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler10.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler11.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler12.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler13.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler14.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler15.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler16.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler17.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler18.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler19.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler2.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler20.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler21.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler22.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler23.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler24.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler25.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler26.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler27.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler28.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler29.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler3.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler30.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler31.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler32.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler33.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler34.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler35.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler36.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler37.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler38.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler39.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler4.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler40.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler41.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler42.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler43.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler44.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler45.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler46.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler47.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler5.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler6.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler7.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler8.log.csv /opt/app/p3wtg1z2/sbpprod1/FW/home/UnifiedLogging/UL_20111013_Scheduler9.log.csv
awk: syntax error near line 1
awk: bailing out near line 1

Where 'a' is ORA (the search string!!)

Thank you in advance Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies

2. UNIX for Beginners Questions & Answers

Using find to output list of files with specific strings

This is my problem, I am using the following code to extract the file names with specific strings 0.01: find ./ -name "*.txt" -exec grep -H '0.01' {} + It works wonders with a small sample. However, when I use it in a real scenario it produces an empty file -even though I am sure there are... (11 Replies)
Discussion started by: Xterra
11 Replies

3. UNIX for Dummies Questions & Answers

Search list of files

Hi All, I Have 2 files. file1: abc.xml.gz abcd.xml.gz xyz.xml.gz X.xml.gz File2 abc. x. cde. unix. My requirment is search File1 using File2 and need below ouput. (6 Replies)
Discussion started by: j.vutakanti
6 Replies

4. Shell Programming and Scripting

Searching for a list of strings in a file with Python

Hi guys, I'm trying to search for several strings, which I have in a .txt file line by line, on another file. So the idea is, take input.txt and search for each line in that file in another file, let's call it rules.txt. So far, I've been able to do this, to search for individual strings: ... (1 Reply)
Discussion started by: starriol
1 Replies

5. Shell Programming and Scripting

Match list of strings in File A and compare with File B, C and write to a output file in CSV format

Hi Friends, I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving... File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Discussion started by: asnandhakumar
6 Replies

6. UNIX for Dummies Questions & Answers

Find Multiple Strings from a list of *.gz files withour decompressing...

Hello Team, There is this situation where there are around 20 *.gz files and i want to search multiple words from all those files. Example as below : filea.gz fileb.gz filec.gz now i want to search words "hi" and "hello" from all these 3 files without... (4 Replies)
Discussion started by: varun87
4 Replies

7. Shell Programming and Scripting

Awk search for a element in the list of strings

Hi, how do I match a particular element in a list and replace it with blank? awk 'sub///' $FILE list="AL, AK, AZ, AR, CA, CO, CT, DE, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA,... (2 Replies)
Discussion started by: grossgermany
2 Replies

8. Shell Programming and Scripting

Want unix script to search a list of strings

Want unix script to search a list of strings (stored line by line in a file), search all the matching lines of files under directories and subdirectories in different unix machines(not one box diff boxes - all the unix box names and username/password are stored with a comma delimitor in flat file)... (2 Replies)
Discussion started by: adminuser
2 Replies

9. Shell Programming and Scripting

list and export strings in a file

Hi all, I have a file looks something like this: ~~~~~~~~~~~~~~~~~~~~~~~~~ aaaa bbbbbb ccc dddddddd ~~~~~~~~~~~~~~~~~~~~~~~~~ I will like a script that can echo line1 export line1 as env variable echo line2 export line2 as env variable etc etc Thanks in advance (3 Replies)
Discussion started by: Avatar Gixxer
3 Replies

10. UNIX for Advanced & Expert Users

Search a list of lines in file into files

I have a file (file1) which is like host1 host2 host3 host4 the list goes on............ Now I want the above lines in files to be compared with files under /opt/new/ File names are as below: Dev Prod QA And suppose host1 from file1 is found under Dev(file under /opt/new)... (2 Replies)
Discussion started by: sriram003
2 Replies
Login or Register to Ask a Question