Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-15-2012, 02:34 PM   #16
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389

Originally Posted by danielbmartin View Post
# 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.

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, 04:07 PM   #17
Senior Member
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Mint 17.3
Posts: 1,694

Original Poster
Rep: Reputation: 561Reputation: 561Reputation: 561Reputation: 561Reputation: 561Reputation: 561
Originally Posted by millgates View Post
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


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

All times are GMT -5. The time now is 06:01 AM.

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