Page 1 of 1

writing a shell script

Posted: Thu Aug 26, 2004 7:07 pm
by Daisy Cutter
im writing a shell script for a blog, and I want to be able to type "./blog.sh" then my content, and write it to a file in the format yyyy-mm-dd.php

so far this is what I have:

Code: Select all

#!/bin/sh
echo $1
pathetic, eh?

I need to do something like write $1 $date.php or something...
I also need to make it so that it will be interpreted as a string or something, because it wont echo more than one word, and any symbols besides letters and numbers break it... thanks
it would also be helpful to have charachters like ' be auto escaped.

thanks to anyone who can help.

Posted: Fri Aug 27, 2004 1:08 am
by scorphus
You could try this:

Code: Select all

#!/bin/sh
date=`date +%Y-%m-%d.php`
echo $1 > $date
References:
- Advanced Bash-Scripting Guide
- $ man date

-- Scorphus

Posted: Fri Aug 27, 2004 7:55 am
by Daisy Cutter
scorphus wrote:You could try this:

Code: Select all

#!/bin/sh
date=`date +%Y-%m-%d.php`
echo $1 > $date
References:
- Advanced Bash-Scripting Guide
- $ man date

-- Scorphus
thanks! I modified that a little so it reads:

Code: Select all

#!/bin/sh
date=`date +%Y-%m-%d.php`
nano $date
so it's easier to edit. a cron job for archiving and ive got me my own blog script that simply outputs a readable directory listing.

Posted: Wed Oct 13, 2004 1:20 pm
by amateen
Salam
Read Bash guide