The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
assitance with sed (repeating patterns) metalwarrior UNIX for Dummies Questions & Answers 7 02-02-2008 01:14 AM
Repeating variables in the code mahalakshmi Shell Programming and Scripting 1 02-08-2007 03:33 AM
Repeating commands in a script Dave2874 Shell Programming and Scripting 4 03-14-2005 06:34 AM
Omit repeating lines TheCrunge UNIX for Dummies Questions & Answers 6 02-22-2005 02:26 PM
Filter out repeating messages antalexi SUN Solaris 2 01-31-2005 10:19 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-02-2008
Registered User
 

Join Date: Feb 2008
Posts: 16
need assistance: sed and repeating patterns

hi,
I need to write a command with sed to find all the lines in a file that contain patterns of three or more characters that repeat once and put them inside perenthezes. I cannot tell sed what pattern to look for. it should find repeated patterns automatically.
example: "firstpatternsecondpattern" would get "first(pattern)second(pattern)" or "1234512345" would get "(12345)(12345)"
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-02-2008
Registered User
 

Join Date: Feb 2008
Posts: 16
nevermind.

I just figured it out.

sed 's/\(.*\{3,\}\)\(.*\)\(\1\)/(\1)\2(\3)/g' file

Last edited by metalwarrior; 02-02-2008 at 01:13 AM.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:51 AM.


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

Content Relevant URLs by vBSEO 3.2.0