LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2011, 11:43 AM   #16
mmrtnt
LQ Newbie
 
Registered: Nov 2006
Location: las vegas, nevada
Distribution: fedora core x
Posts: 25

Rep: Reputation: 8
Too Late?


Quote:
Originally Posted by angel115 View Post

I'm trying to match a pattern spreadout on multyple line. (without success until now)

Ex: "test.txt"
Code:
The cat
in the street
Look nice
I want to be able to match
"The cat
in the street"
for example
I was searching for multiline grep when I came across this thread, so I thought I'd drop off my solution:

(Assuming bash)
Code:
while read line; do echo "$line" | grep "The cat"; echo "$line" | grep "in the street"; done < test.txt
(The awk solution is a lot cleaner, however, but this is a way to use just grep)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to replace string pattern with multi-line text in bash script? brumela Linux - Newbie 6 04-21-2011 06:56 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 06:17 AM
Script Help: How to count a matching pattern in one line? dv502 Programming 3 12-13-2008 01:53 PM
pattern matching in file amitpardesi Linux - Software 5 02-08-2008 07:06 AM
pattern matching nadeemr Linux - Newbie 8 06-13-2007 11:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration