writing a shell script

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
Daisy Cutter
Forum Commoner
Posts: 75
Joined: Sun Aug 01, 2004 9:51 am

writing a shell script

Post 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.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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
Daisy Cutter
Forum Commoner
Posts: 75
Joined: Sun Aug 01, 2004 9:51 am

Post 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.
amateen
Forum Newbie
Posts: 1
Joined: Wed Oct 13, 2004 1:07 pm
Location: Pakistan
Contact:

Post by amateen »

Salam
Read Bash guide
Post Reply