LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-05-2011, 12:14 PM   #1
shak4031
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
sed find and replace with wildcard


I would like help with modifying the following content:

toolbox/perl/man/man3/ExtUtils::Command.3::Command.3 differ
toolbox/perl/man/man3/ExtUtils::Command::MM.3::Command::MM.3 differ


I would like the content to be changed to:

toolbox/perl/man/man3/ExtUtils::Command.3
toolbox/perl/man/man3/ExtUtils::Command::MM.3

I was not sure how to tell sed what to look for?

I tried the following but it did not work.
sed -i 's/::* differ//g' mandiff.log
 
Old 08-05-2011, 12:55 PM   #2
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 450Reputation: 450Reputation: 450Reputation: 450Reputation: 450
Quote:
I would like help with modifying the following content:

toolbox/perl/man/man3/ExtUtils::Command.3::Command.3 differ
toolbox/perl/man/man3/ExtUtils::Command::MM.3::Command::MM.3 differ


I would like the content to be changed to:

toolbox/perl/man/man3/ExtUtils::Command.3
toolbox/perl/man/man3/ExtUtils::Command::MM.3

I was not sure how to tell sed what to look for?

I tried the following but it did not work.
sed -i 's/::* differ//g' mandiff.log
windows_vista shak4031 is online now Add to shak4031's Reputation Report This Post
Welcome to LQ,

try this:
Code:
sed -r 's/(::.*)\1.*/\1/'
Worked with the sample that you provided in your first post.
 
1 members found this post helpful.
Old 08-05-2011, 04:10 PM   #3
shak4031
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks!!...that worked although i couldn't follow it...Have some reading to do i guess.

One more type was left in file...Hoping you can help.

toolbox/perl/man/man3/File::Temp.3smartstoolbox/perl/man/man3/File::Temp.3 differ
toolbox/perl/man/man3/XML::Temp.3smartstoolbox/perl/man/man3/XML::Temp.3 differ

Convert to:
toolbox/perl/man/man3/File::Temp.3
toolbox/perl/man/man3/XML::Temp.3
 
Old 08-05-2011, 04:17 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,620

Rep: Reputation: 450Reputation: 450Reputation: 450Reputation: 450Reputation: 450
Quote:
Originally Posted by shak4031 View Post
One more type was left in file...Hoping you can help.

toolbox/perl/man/man3/File::Temp.3smartstoolbox/perl/man/man3/File::Temp.3 differ
toolbox/perl/man/man3/XML::Temp.3smartstoolbox/perl/man/man3/XML::Temp.3 differ

Convert to:
toolbox/perl/man/man3/File::Temp.3
toolbox/perl/man/man3/XML::Temp.3
That is why you should always provide a representative example. The new sample can be included with the following
Code:
sed -nr 's/(::.*).*\1.*/\1/p'
 
1 members found this post helpful.
  


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
find or replace without using sed adarshmca Linux - Newbie 9 12-28-2010 06:41 AM
find or replace through sed adarshmca Linux - Newbie 3 12-28-2010 12:35 AM
sed - multiline search/replace with wildcard troubles Yalla-One Programming 4 12-29-2008 01:01 PM
sed - find and replace command bullshit Programming 9 01-05-2006 04:25 AM
SED;find and replace;help required gd13 Programming 3 12-21-2004 07:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration