LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   sed and rename text in file (http://www.linuxquestions.org/questions/programming-9/sed-and-rename-text-in-file-861791/)

cober 02-10-2011 05:57 AM

sed and rename text in file
 
I need a help with sed and renaming the text in file, so I'd be very pleased if anyone can help me with that.

Let's say we have this one:
Code:


       
Quote:

       
       
               
       
       

                       

                       
                               

                                        Originally Posted by nickname
                                       
                               

                               
nickname presents: $subject
Size: size
 

Click on the picture to view it in full size
[img]www.blabla.com/img.jpg[/img]
NFO:
[nfo]RELEASE..: $release
 VIDEO....: $video
 DATE.....: $date
 FILES....: $files
 URL......: $url

 NOTES

 blablabla.[/nfo]
 
This message has been hidden
 
[nfo]***************************************************************************************
 some text which i want to be removed 
***************************************************************************************[/nfo]

                       
                       

               


First of all, I'd like to remove
Code:

quote tags.
Second, where is
Code:

[b]nickname presents:
to

Code:

[b]cober presents:
[nickname changed to cober]

Third, also want to be removed this line
Code:

url=link[img]www.blabla.com/img.jpg[/img]/url
and instead of that, I'd want to put my own link, as example
Code:

url=newlink[img]newlink[/img]/url
Fourth, there we have
Code:

[nfo]
and
Code:

[/nfo]
which are useless, so I'd need to remove that one like as up there.

And, finally we have something like:
Code:

This message has been hidden
 
[nfo]***************************************************************************************
 some text which i want to be removed 
***************************************************************************************[/nfo][/quote]

I'd like here to remove complete text.



I'd very appreciate any help related to this post, hope there is no much work, otherwise I can also pay someone to make this for me.

Thanks again!!!

cober 02-10-2011 07:15 AM

Hello,

Small update.

Can anyone tell me how to delete the last 4 lines from a file using a sed? :)

Tinkster 02-10-2011 03:30 PM

Code:

sed -e :a -e '$d;N;2,4ba' -e 'P;D'


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