Date & time as dir name
I am trying to write a shell script that will creat a directory with the current date and time as name (mkdir /home/??), then move some files into it (mv /home/cam/*.avi /home/??). This is for a security cam setup, using lavrec as the recorder. Any sugestions for syntax?
|
The command you will want to execute at the prompt to get the date and time is:
Code:
$ date +%m-%d-%Y-%H:%M Code:
3-15-2006-20:11 Code:
#!/bin/zsh |
Well; Almost
Tried that code verbatum. Got zip. Played with it for awhile, and finally got to:
cd /home/cam CUR_DATE='date +%m%d-%Y-%H:%D' mkdir $CUR_DATE mv /home/cam/*.avi /home/cam/$CUR_DATE which got me a directory called "+%m%d-%Y-%H:%D", with a directory called "date" in it, along with all of the avis. It's close, but is not reading the format. I'm using bash in Mandriva. Any chance that's my problem? |
Notice that CUR_DATE=`date +%m-%d-%Y-%H:%D` is not encapsulated with aposterphies, it uses the character that is next to the number one on the keyboard. This tells the script to execute the command "date". Copy and paste my script, you will see that it does work.
|
Yer rite! It works now.
That's what happens when you get old. You can't see. Increased my font size and saw what you told me. I beat my head against the wall for 3 days on that one. Thank you very much for your help. |
If you don't want to use backquotes, try using the out=$(command) syntax instead.
Note also that you can play around with the format of the dates by changing the date command appropriately. |
Date & time as dir name
Did that. Got the format the way I wanted it, then added a tar/zip line. Thing works smooth as a baby's bum. That's why I love Linux so much. Get stuck on something, and people trip over themselves to help you. Where else in the world do you see that attitude?
|
All times are GMT -5. The time now is 09:27 AM. |