Re: [SLUG] bash script problem

From: Eben King (eben1@tampabay.rr.com)
Date: Wed Oct 05 2005 - 21:37:08 EDT


On Wed, 5 Oct 2005, Ron Youvan wrote:

> I need to create a new file every 24 hours and start appending
> these incoming strings into the new file.
> I want to name the files with the current date, so:
> "at" midnight the file: date +.+ log needs to be created,
> such as 12-25-05.log (for next Christmas) as an example.
> I can divert date's string into a file as a text string,
> but I haven't been able to create a file named from date.

date_args=%G_%m_%d
linkname=/tmp/write_here
filename="/tmp/`date +$date_args`"
touch "$filename"
ln -sf "$filename" "$linkname"

or if you don't like all the fancy stuff,

touch "/tmp/`date +%G_%m_%d`"

and have no link.

> man date says: "date - print or set the system date and time"
> It prints the system time, but getting it into a variable
> seems to be my problem.
> I have tried everything that I can think of including:
> touch < date (+formatting info)
>
> Can anyone please point me in the proper direction?

Backquotes aka $(...) are your friends.

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar
CAPRICORN:  The stars say you're an exciting and wonderful person...
but you know they're lying.  If I were you, I'd lock my doors and
windows and never never never never leave my house again.  -- Weird Al

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:57:33 EDT