473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

search for an occurence of two text in a list of files

2
I'm trying to find files in the current directory that have the occurence of '<IWM_Datasource>NOUID</IWM_Datasource>' AND '<IWM_HasMetaData>true</IWM_HasMetaData>'.

I was able to find just the first text like this:
find . -name '*Base*xml' -type f -exec egrep -l ^.*'<IWM_Datasource>NOUID</IWM_Datasource>'$ {} /dev/null \;

But when I try to add the second text I don't seem to get it right, can any1 help?

Regards,
May 26 '07 #1
4 1404
ghostdog74
511 Expert 256MB
I'm trying to find files in the current directory that have the occurence of '<IWM_Datasource>NOUID</IWM_Datasource>' AND '<IWM_HasMetaData>true</IWM_HasMetaData>'.

I was able to find just the first text like this:
find . -name '*Base*xml' -type f -exec egrep -l ^.*'<IWM_Datasource>NOUID</IWM_Datasource>'$ {} /dev/null \;

But when I try to add the second text I don't seem to get it right, can any1 help?

Regards,
Expand|Select|Wrap|Line Numbers
  1. awk '/IWM_Datasource/ && /IWM_HasMetaData/ { print "Found in " FILENAME}'  *Base*xml
  2.  
May 26 '07 #2
Caldas
2
Expand|Select|Wrap|Line Numbers
  1. awk '/IWM_Datasource/ && /IWM_HasMetaData/ { print "Found in " FILENAME}'  *Base*xml
  2.  
Thx for the code.

I tried it and got no hits, but when I change the && operator to || then it returns the file twice as if it was searching twice, once for each part of the condition.

Any ideas why the && wouldn't work? These are not in the same line, but exist in the same file.

Regards,
May 27 '07 #3
ghostdog74
511 Expert 256MB
Thx for the code.

I tried it and got no hits, but when I change the && operator to || then it returns the file twice as if it was searching twice, once for each part of the condition.

Any ideas why the && wouldn't work? These are not in the same line, but exist in the same file.

Regards,
the syntax: /<somepattern> && /<someotherpattern>/ means to search for these 2 patterns together on the same line. I suspect the 2 patterns you mentioned are on different lines, that why you got nothing. what's you actual reqiurement again? do you want to find them on the same line together? or do you want to find these 2 , no matter which line they are in? also post another example of your sample input file.
May 27 '07 #4
pbmods
5,821 Expert 4TB
You could just modify your regular expression (though I sure hope this isn't the best way to do it):

Expand|Select|Wrap|Line Numbers
  1. '(<IWM_Datasource>NOUID<\/IWM_Datasource>)|(<IWM_HasMetaData>true<\/IWM_HasMetaData>)$'
  2.  
May 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sharif T. Karim | last post by:
I am trying to do the following with my search script that looks for records in a mysql table. The following is an example of what I am trying to do. Text being searched: -- The brown fox...
4
by: Jane Doe | last post by:
Hi, I need to search and replace patterns in web pages, but I can't find a way even after reading the ad hoc chapter in New Rider's "Inside JavaScript". Here's what I want to do: function...
19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
12
by: Vjay77 | last post by:
Hi, I haven't posted any problem in quite a while now, but I came to the point that I really need to ask for help. I need to create an application which will search through .txt log file and...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
5
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the...
16
by: Computer geek | last post by:
Hello, I am new to VB.NET and programming in general. I have taught myself a lot of the basics with vb.net but am still quite the novice. I am working on a little application now and I need some...
15
by: ritesh | last post by:
Hi, I'm working on a piece of code that - 1. has a list of text files 2. and needs to search for a particular expression in these files (this is being done on Linux using gcc 3.4.2) ...
3
by: mercuryshipzz | last post by:
#!/usr/bin/perl #use strict; use warnings; sub search_pattern { my $file_name = $_;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.