LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-18-2003, 03:18 PM   #1
letmein
LQ Newbie
 
Registered: Jul 2003
Posts: 24

Rep: Reputation: 15
perl with sed !!!


can any one help me how can i integrate perl with sed ?
what i am trying to do is convert some URL's for ex:

/home/temp/myfolder/welcome.html
/usr/local/bin/auto.sh
/home/temp/classes/index.html

into URLs like this:


temp/myfolder/welcome.html /***** removing the root folder of each URl ***/
local/bin/auto.sh /**** but the root's are not the same for all ***/
temp/classes/index.html /**** this URL's are dynamically generated **/
/***its not fixed or not the same for all the URL's */

does any one know how can i do this?

looking forward for some good answers !!!

( USING PERL & sed/awk/any other regular expression method)
 
Old 08-18-2003, 05:26 PM   #2
bruce1271
Member
 
Registered: Apr 2003
Location: Dallas, TX
Posts: 122

Rep: Reputation: 15
Well, You say random, but there are only so many root directories.

so I would do this. % cat orig.html |sed "s/\home//g" |sed "/\/local//g" > new.html. Keep piping it through sed to search and replace all occurances. Or you can write a while loop in perl and do the same, one line at a time.

#!/usr/bin/perl

while(<>){
$_=~s/^.*?\/home//g;
print $_;
}
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on sed and perl needed. cash_05 Programming 7 09-03-2005 04:33 PM
SED, AWK or PERL HELP embsupafly Programming 6 08-20-2005 09:07 PM
using sed with parentheses in perl beebop Linux - General 2 07-21-2005 10:41 PM
conting repeated substrings:SED perl anirudh Programming 1 10-29-2004 01:01 PM
SED + perl !!! letmein Linux - General 9 10-07-2003 05:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:12 PM.

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
Open Source Consulting | Domain Registration