LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-19-2014, 12:43 PM   #1
thealmightyos
Member
 
Registered: Mar 2009
Distribution: CentOS 6.5 / 7
Posts: 119

Rep: Reputation: 1
ack/sed, locate website address(s) in file and format in bbcode url


ok, this is going to be a real easy answer for somebody. I just know it.

First the basics: created a script that 1.)ran an SQL query and output to an HTML file. Then 2) ran it though another script that made it suitable to post on a forum like this one and lastly 3) print it out so it can be copied and pasted. Very simple stuff:

Code:
(sql query -> forum.post)
sed -i.bak s/\</\[/g forum.post
sed -i.bak s/\>/\]/g forum.post
sed -i.bak "s/TABLE[ ]BORDER=1/Table=\"class: grid, width: 100\%, align: center\"/g" forum.post
cat forum.post
Something makes me think I got some help from here on it, forgot a \ or something...

Anyway, moving on...

The script works flawlessly. It turns an HTML table into BBCode table. However, there is an issue. The database contains some web addresses (http://test.site.com/folder/page) and I would like to make them clickable in my bbcode table. I know there is a way to do this. I can find "HTTP://" because all addresses start with that, but they are all variable lengths.

Not to mention, the bbcode for url's goes something like this:
Code:
[ URL="http://test.site.com/folder/page" ]text here[ /URL]
(had to put spaces in to make it show up, even in code tags)
So not only do I have to wrap the address within the tags, I will also need to insert a text block between them.

Any suggestions?

Last edited by thealmightyos; 11-19-2014 at 12:48 PM.
 
Old 11-26-2014, 03:41 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,481

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
If you're going to paste things in to an edit box in a forum then you'll find that most forums are set up to do the detection of the urls and turn them in to links automatically on the forum side.
 
Old 05-05-2015, 10:37 AM   #3
thealmightyos
Member
 
Registered: Mar 2009
Distribution: CentOS 6.5 / 7
Posts: 119

Original Poster
Rep: Reputation: 1
Fortunately I am not working on that project anymore. It was a headache anyway. Thank you for the assistance. Thread can be closed
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace IP address string in a file using sed finekevin Linux - Newbie 2 01-18-2012 07:16 PM
[SOLVED] [Help] format text file for import into SQL table (with sed or similar) totaluser Linux - Newbie 3 11-05-2011 03:57 PM
Sed, and how to get the file name from an URL the who Programming 2 06-08-2004 01:20 PM
how does a brower get URL address info when the website is hiding it? sirpelidor Programming 3 12-05-2003 09:33 PM
convert html file to latex format using sed? BigHeadDog Linux - Newbie 2 12-01-2003 11:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:17 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
Open Source Consulting | Domain Registration