Help renaming a directory!

Ok so renaming a directory is easy in unix. But here is the difficult task:

Im using the tcsh shell to write a basic script that moves certain logs to a folder at a certain time. This folder's name needs to be the current date. Moving the files is simple, but automatically generating a directory with the current date has proven difficult.

Can anyone help me?
 
Try using the date command, like this:

$ mkdir test-`date +%F`-dir
$ dir -ld test*
drwxrwxr-x 2 tom tom 4096 Mar 3 14:26 test-2006-03-03-dir
$

Read the man page on the various formatting options and specify them after the "+" sign as appropriate. Be sure to keep the single quote marks (`), as I have in my example above, as they instruct the shell to run the command enclosed in them and substitute the output in place where the command appears.

Good luck!

Peace...
 
tomdkat you are the man...lol

Thanks for taking the time to help me with this. I will format it to my needs but I got the just of it. I'm glad to see that i can count on this forum and its members.

Thanks again!
 
Naw, I'm not "the man"... just trying to help out. :)

I've used the date command to do things like naming files based on a date/time stamp and it can work out very well when used right.

Good luck and let us know how it works out for you. :)

Peace...
 
artov said:
On the tcsh shell: check http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Ok, it is about csh, but to my knowledge tcsh is mainly enhanced commandline
stuff (edition etc.). So: use bash or sh instead.
I dunno, I've used csh, tcsh, bash, sh, and ksh and I don't see any problem with using csh. I do agree that one should also be proficient in sh (even more so than ksh or bash) in the interest of being functional across a broader spectrum of *nix systems.

In this case and for what he's wanting to do, (t)csh will work just fine. :)

Peace...
 
Back
Top