473,498 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 1407
ghostdog74
511 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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 Recognized Expert Expert
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
2183
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
10182
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
13538
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
6401
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
9524
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
2681
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
2821
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
2104
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
1822
by: mercuryshipzz | last post by:
#!/usr/bin/perl #use strict; use warnings; sub search_pattern { my $file_name = $_;
0
6993
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
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6881
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
7375
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...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.