The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Searching all files that contain pattern ravi.sadani19 Shell Programming and Scripting 4 5 Days Ago 03:52 PM
Pattern searching pattern in c files murthybptl Shell Programming and Scripting 6 11-17-2007 06:15 AM
Regarding Searching Pattern sbasetty Shell Programming and Scripting 2 09-29-2006 02:49 PM
Searching for a pattern in a Directory gandhevinod Filesystems, Disks and Memory 1 02-25-2005 05:35 AM
pattern searching using C giannicello High Level Programming 1 04-16-2002 09:53 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-22-2006
Registered User
 

Join Date: Aug 2005
Posts: 13
How to use cat command in sed pattern searching

Hi All,

I have a file named pattern.dat which contains pattern like
A1000090 250.00 250.00

i have one more file named test.dat in which this pattern is present.

What i should do is, in test.dat after this pattern i should append comments.

i used like this

sed "/`cat pattern.dat`/ a\
> COMMENT
> " test.dat

It is throwing error as
sed: command garbled: /A1000090 250.00 250.00 / COMMENT

please help me out to solve this probelm.

Thanks,
Sona.
Reply With Quote
Forum Sponsor
  #2  
Old 08-22-2006
Registered User
 

Join Date: Aug 2006
Posts: 69
Dear Sona,

The error you are getting is probably because you are using "" on place of ''.
You can try this also.....it's little ugly but I think it might solve your purpose.....

sed '/[a-zA-Z0-9]* [0-9]*\.[0-9]* [0-9]*\.[0-9]*/ a\
COMMENT
' pattern.dat > test.dat

regards
Apoorva kumar
Reply With Quote
  #3  
Old 08-22-2006
Registered User
 

Join Date: Aug 2005
Posts: 13
Hi Apoorva,

I think u misunderstood my query...

I just want to search the pattern(present in pattern.dat) in test.dat and append a new line after that pattern in test.dat.

I tried with ur code..it is not working.

Thanks,
Sona.
Reply With Quote
  #4  
Old 08-22-2006
Registered User
 

Join Date: Aug 2006
Posts: 69
Ok ! Let me check it!!

regards
Apoorva kumar
Reply With Quote
  #5  
Old 08-22-2006
Registered User
 

Join Date: Aug 2005
Posts: 13
But the pattern should be taken from one file.It is not just any string we can use. so how can i do that?

how can i take the pattern from one file and check it in another file using sed since i need to append the comment text after that pattern.

Sona.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0