Results 1 to 3 of 3
This probably isn't the best way to do this, but it sort of works.
Code:
echo "#CMS.sh"
echo -n "Title of post: "
read title
echo -n "Text: "
read ...
- 04-22-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 1
Help with my "CMS" in bash
This probably isn't the best way to do this, but it sort of works.
what I want to do is add new text to an html file so that it appears at the top of the page.Code:echo "#CMS.sh" echo -n "Title of post: " read title echo -n "Text: " read text echo "<i>" >>date date >>date echo "</i>" >>date echo "<p>" >>new.html cat date >>new.html echo "</p>" >>new.html echo "...................." >>new.html echo "<h1>"$title"</h1>" >>new.html echo $text >>new.html cat index.html >>old.html cat old.html >>index.html cat new.html >>index.html rm -f new.html old.html date
The following is what I get when I run it:
I'm trying to get it to look likeCode:Tue Apr 15 22:34:48 CDT 2008 .................... old title old text Tue Apr 15 22:34:53 CDT 2008 .................... new title new text Tue Apr 15 22:34:48 CDT 2008 .................... old title old text
<new post>
<old post>
Thanks in advanced for any help.
- 04-23-2008 #2
Read all about BASH Programming - Introduction HOW-TO scripting as a starter.
- 04-23-2008 #3Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
So, what you need is to *reverse* the order in which the posts are stored, if I got it correctly.
You can't do that directly, but there's an easy way. Let's say that you store all the posts in a file called posts.txt. You can dump the new info into tmp.txt with echo, then cat posts.txt >> tmp.txt, and finally rename that file what will be the new posts.txt.


Reply With Quote
