sed command backreference question
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > sed command backreference question




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    sed command backreference question  
Braveheart


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-24-05 10:58 PM

Hello,

I would like to execute another command from within the sed command,
similar to the following (this is just an example of what I want to
do):

echo $LIST | head -30 | sed "s/\(.*\)~\(.*\)~\(.*\)/`ls \2`/"

This doesn't work because the backreference is not expanded in the `ls
\2` section.  Is there any way to do this?

Thanks!






[ Post a follow-up to this message ]



    Re: sed command backreference question  
John W. Krahn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-25-05 07:51 AM

Braveheart wrote:
>
> I would like to execute another command from within the sed command,
> similar to the following (this is just an example of what I want to
> do):
>
> echo $LIST | head -30 | sed "s/\(.*\)~\(.*\)~\(.*\)/`ls \2`/"
>
> This doesn't work because the backreference is not expanded in the `ls
> \2` section.  Is there any way to do this?

echo $LIST | head -30 | PERL -pe's/(.*~(.*)~.*)/-e $2 ? $2 : $1/e'


John
--
use Perl;
program
fulfillment





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:02 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register