LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-15-2012, 01:34 PM   #16
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 651

Rep: Reputation: 269Reputation: 269Reputation: 269

Quote:
Originally Posted by danielbmartin View Post
Code:
# Find words which contain
# at least 3 of the same character.
# Use sed to mimic grep.
cat < $WrdLst                    \
|sed -n '/\(.\).*\1.*\1/p'       \
> $Work09
You're almost there. The problem is the 'p' command will not modify the matching line.
You can combine it with 's', though.

Code:
sed -n 's/.*\(.\).*\1.*\1/\1 &/p'
where I used '&' to reference the entire matched expression. I also had to add a '.*' at the begining of my regex to match the begining of the word.
 
1 members found this post helpful.
Old 02-15-2012, 03:07 PM   #17
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,065

Original Poster
Rep: Reputation: 284Reputation: 284Reputation: 284
Quote:
Originally Posted by millgates View Post
Code:
sed -n 's/.*\(.\).*\1.*\1/\1 &/p'
Another home run for millgates! I hope you enjoy solving these character-string brain teasers. Thank you!

Daniel B. Martin
 
  


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
[SOLVED] Choosing words based on length danielbmartin Linux - Newbie 3 11-30-2011 01:14 PM
count lines and words lipun4u Linux - Newbie 2 02-15-2010 01:39 AM
Select only words with a letter Coimbra Linux - Newbie 6 07-04-2007 08:45 AM
Script to move directories based on first letter to a new directory of that letter tworkemon Linux - Newbie 8 01-30-2007 07:18 PM
Mandy 9.2- Passwords have become 5-6 letter words I can't change. Mitsurugi Mandriva 0 03-20-2004 10:31 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration