conditional multiple string matching


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting conditional multiple string matching
# 8  
Old 11-13-2010
@danmero : this is exactly what my command does !

( b1b && d1d ) && ( a1a || c1c ) ...
# 9  
Old 11-13-2010
Thanks a lot for everyone. test script is working.. I am testing it in a larger context.

I am hoping there is no better way of doing this kind multiple string searching sprinkled in a file conditionally. If there is one please share.

---------- Post updated at 09:42 AM ---------- Previous update was at 09:38 AM ----------

becket,
What you are trying to help me with is searching for multiple strings in the file Names. But my question was to find them in the file contents.

Please read the question and test data I gave carefully.
# 10  
Old 11-13-2010
Sorry Smilie My misunderstanding
# 11  
Old 11-13-2010
Well it is quite understandable since the OP's post is a bit contradictory IMO. I am assuming the OP is looking for what Jim suggested in post #2. Then this could be used in the find exec:
Code:
awk '/b1b/{a=1}/d1d/{b=1}/a1a|c1c/{c=1} END{if(a&&b&&c)print FILENAME}'


Last edited by Scrutinizer; 11-13-2010 at 12:06 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Conditional string search

Hi, I need to search/grep userid and its value based on a condition that the user id is under the heading "*central_test*" in a big file of about 70808MB. The * represents some strings before and after the string "centrla_test". Could anyone please guide. OS is hp-ux. (2 Replies)
Discussion started by: sam_bd
2 Replies

2. Shell Programming and Scripting

Problems with Multiple Pattern String Matching

I am facing a problem and I would be grateful if you can help me :wall: I have a list of words like And I have a datafile like the box of the box of tissues out of of tissues out of the book, the the book, the pen and the the pen and the I want to find Patterns of “x.*x” where... (2 Replies)
Discussion started by: A-V
2 Replies

3. Shell Programming and Scripting

awk if conditional, multiple lines

Hi experts, I have a file with hundreds of lines that looks something like this: Cake 1 3 4 2 3 1 3 Onion 3 2 4 1 3 4 2 Apple 2 3 4 4 1 2 1 Orange 4 3 4 1 2 4 1 Cake 3 1 4 2 4 2 1 Onion 2 4 2 1 4 2 1 Apple 4 3 3 3 3 2 1 Orange 2 1 2 2 2 4 1 Cake 4 3 4 3 1 3 3 ... I'm trying to... (2 Replies)
Discussion started by: david_seeds
2 Replies

4. Shell Programming and Scripting

Matching string from input to string of file

Hi, i want to know how to compare string of file with input string im trying following code: file_no=`paste -s -d "||||\n" a.txt | cut -c 1` #it will return collection number from file echo "enter number" read " curr_no" if ; then echo " current number already present" fi ... (4 Replies)
Discussion started by: a_smith
4 Replies

5. Shell Programming and Scripting

String matching

I have a string like ab or abc of whatever length. But i want to know whether another string ( for example, abcfghijkl, OR a<space> bcfghijkl ab<space> cfghijkl OR a<space>bcfghijkl OR ab<space> c<space> fghijkl ) starts with ab or abc... space might existing on the longer string... If so, i... (4 Replies)
Discussion started by: nram_krishna@ya
4 Replies

6. Shell Programming and Scripting

Matching multiple values in a string

I've been battling with parsing a comma-delimited string, and have had what I would call B- success. I'm using perl and trying to parse out specific identifiers from a string, into a new string. When things are "normal," my regex works fine. When things get complicated, my script fails... (1 Reply)
Discussion started by: linber2880
1 Replies

7. Shell Programming and Scripting

sed conditional string replace for each line

Hi all, I appreciate the enormous amount of knowledge that flows in this forum. I am an average UNIX user. I have many files with lines like the below. I have separated each line with space for ease of reading. I need to replace the first occurance of "/00" with null on those lines that have... (6 Replies)
Discussion started by: Nanu_Manju
6 Replies

8. UNIX for Dummies Questions & Answers

Matching string

Hello, i have a program where i have to get a character from the user and check it against the word i have and then replace the character in a blank at the same position it is in the word. (7 Replies)
Discussion started by: nehaquick
7 Replies

9. Shell Programming and Scripting

String matching

for a certain directory, I want to grep a particular file called ABCD so what I do is ls /my/dir | grep -i "ABCD" | awk '{print $9}' however, there is also this file called ABCDEFG, the above command would reurn both file when I only want ABCD, please help! (3 Replies)
Discussion started by: mpang_
3 Replies

10. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies
Login or Register to Ask a Question