Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Bash Scripting Question...
Old 01-01-2011, 04:08 PM Bash Scripting Question...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Hi,

Can someone show me some bash scripting code that will generate a bunch of html pages based on filenames from a list of names in a text file?

For example, I have a file called categories, and in that text file there will be one category per line (no separation, just a line break or Carriage Return ) and I would like to run a bash script against that category file, and would want the output to be to create an html document using the appropriate html markup for each category in that file. Of course, I would want the pages to be created in the directory in which the script runs from. The html markup would be just an empty html doc, with the basic html, head, title, and body tags (open and close tags)

Thanks alot guys!
By the way, I like new logo / site name! Excellent! I love fishing, so I love the Big Fish part!
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 01-01-2011 at 04:10 PM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-01-2011, 08:11 PM Re: Bash Scripting Question...
Super Talker

Posts: 101
Name: Hanmore Jemimah the Fourth
Location: the front line
Trades: 0
Say file judeans has...

reg
stan
loretta

Code:
cat judeans | sed 's/^/cp template /g' | sed 's/$/\.html/g'
Gives output:

Code:
cp template reg.html
cp template stan.html
cp template loretta.html
and to make it just go ahead and create them from 'template' (which you have prepared earlier) do

Code:
cat judeans | sed 's/^/cp template /g' | sed 's/$/\.html/g' > myprog; sh myprog;
Remember to create "template" first, obviously. And on the off chance that the user running the command has no write permission on the directory, use 'touch' to create a file and chmod it appropriately. For example in a separate commandline burst or indeed if you wanna juggle like a juggler have a go at shoving it into one commandline burst (the "tee" funnel thingy will probably be useful for such a purpose).

Last edited by CannonFodder; 01-01-2011 at 08:18 PM..
CannonFodder is offline
Reply With Quote
View Public Profile
 
Old 01-02-2011, 09:45 AM Re: Bash Scripting Question...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Thank you very much!
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Bash Scripting Question...
 

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21496 seconds with 12 queries