Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 03-07-2005, 08:24 PM   #1
Registered: Dec 2003
Location: Hong Kong SAR
Distribution: Slackware 9.1, 10.x, slackware-current
Posts: 186

Rep: Reputation: 30
Generate files using bash

Hi all,

Is it possible to generate a html file based on an input file of which there are only 2 columns? A tab is in between the 2 columns.

bold http://localhost

The output will be:
<head> ....... </head>

Thanks. Any help would be appreciated.

P.S. I am still new to bash programming.
Old 03-08-2005, 01:59 PM   #2
LQ Newbie
Registered: May 2004
Distribution: Gentoo (main box, mythtv and laptop)
Posts: 14

Rep: Reputation: 0
Bash can do pretty much anything. I think there are wikis written in bash.

But mainly, it seems like the stream editor "sed" is your friend here. If what you want to do is basically cue off of one column to format another, sed takes care of business pretty well.

For example:


# This is where we'll do the heavy lifting
sed 's_italic\t\(.*\)_<i>\1</i>_' test.txt > temp0.html
sed 's_bold\t\(.*\)_<b>\1</b>_' temp0.html > temp1.html

# Now create the final file...
echo '<html>' > index.html
cat temp1.html >> index.html
echo '</html>' >> index.html

# and clean up...
rm temp0.html temp1.html
So, what I've done is used some temp files to store your main text file between sed commands, and used sed to pick out the the lines with specific formatting information and re-encode that into html. In the second part (creation of the final file), you can put whatever other html code you like before and after the sed-processed code.

Hope this helps.



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

Similar Threads
Thread Thread Starter Forum Replies Last Post
can bash generate random digit? sorno Linux - Newbie 5 08-17-2005 06:05 AM
"How to Generate PHP files Dynamically" manikantha Programming 5 09-26-2004 12:00 PM
making .tif files into animated .gif files (bash shell, Red Hat 7.2) illiniguy3043 Linux - Newbie 1 06-01-2004 04:04 PM
Foomatic: How to generate ppd drivers from xml files? johnny1959 Linux - Newbie 0 02-17-2004 04:27 AM
Generate PostScript files with CUPS AcerKev Linux - Software 7 09-05-2003 09:41 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:18 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration