Creating a file with the date in it


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Creating a file with the date in it
# 1  
Old 05-08-2001
Java

I would like to create an archive of backup files
In doing so I would like to be able to create a file basically called

filname.`date`.arch

With each try I get something completly different - so how do I get just say zip the entire directory >

filename.may092001.arch

Any ideas - I really botched that one - I need to know how to get all the other characters outta the date command and then use it as a variable to make the filename.
# 2  
Old 05-09-2001
hey n9ninchd
I'm not sure if I understood your question, but if you just want the numerical date format you can just specify the date command to be format thus:

`date "+%m%d%y"` which will return 050901 for example (todays date - 9th May 2001)

Hope this helps.

Regards
alwayslearningunix
# 3  
Old 05-09-2001
if you have gnu date & tar:
use
Today=`date +%d-%B-%Y`     # 09-May-2001
tar czvf $Today.arch.gz dirname

HTH
# 4  
Old 05-09-2001
Thank You to the both of you.
Both scenarios work well, and both work in the areas that I needed.

Once again thank you so much
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Creating dir with date and then increment by 1

Hi, I can't seem to do this or find how to do it. Can someone please help: I have a dir and within it I have dirs with date name example Test1/ 2017-08-12 2017-09-13 2017-10-14 2017-11-15 2017-11-16 what I want is a a script to scan the above and then take 2017-11-16 and increase this... (10 Replies)
Discussion started by: israr75
10 Replies

2. UNIX for Dummies Questions & Answers

Creating a directory based on date

I want to create a directory based on date. I do not have date -d command. What I do have is: either use "date" command to get current date or DATE1=$(perl -e 'print scalar(localtime(time - 1 )), "\n";' |awk '{print $2,$3,$5}') |awk '{print $3}'can be modified to produce the desired year.... (3 Replies)
Discussion started by: newbie2010
3 Replies

3. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

4. Shell Programming and Scripting

Help with creating a text file in perl with file creation date.

Hi, I am quite new to Perl scripting and i need to create a .TXT file using perl, with fields (A,B,C,D,E), and this text file should be named with current file creation date "XYZ_CCYYMMDD.TXT" (i.e.XYZ_2011042514:33 PM). Can anyone who has done this, please share their expertise on this... (5 Replies)
Discussion started by: msrahman
5 Replies

5. Shell Programming and Scripting

creating a file name based on date

I need to automate a weekly process of piping a directory list to a csv file. Normally I do ls -l > files_04182010.csv (04182010 being the date..) Can someome show me how I would script this, so that when the script is ran it grabs the current date and formats it and allows me to use that... (8 Replies)
Discussion started by: jeffs42885
8 Replies

6. Shell Programming and Scripting

Creating a date (without time) in perl

I have a perl script that automatically runs on Mondays. I need to have it create a variable for last Monday's date thru that Sunday's date. example: 04-01-2011 thru 04-08-2011 Its reporting numbers for the previous week beginning with Monday and ending on Sunday. So i dont have to go in... (7 Replies)
Discussion started by: bbraml
7 Replies

7. Shell Programming and Scripting

Need help on creating a file everday with current date

Hi Friends/Team, I have written a small script but I dont understand what is the mistake in this one.. please help me identify and correct it. file="touch `date +%b_%d`" for i in $(cat /home/gmanju/servers) do echo $i >>file remsh $i cat /var/opt/omni/server/log/opcmsg.log | grep -i... (1 Reply)
Discussion started by: gmanjunathbe
1 Replies

8. Shell Programming and Scripting

creating a new file with date stamp

Hi, can any one tell me how to achieve this...I will input the path and file name and it should rename it to current date and time... this is what I tried... #! /usr/bin/sh set -x cd /info_stg/vul/Scripts TODAY_DATE_TIME=`date +%Y%m%d%H%M%S` IN_FILE_PATH=`cat file.txt | awk -F, '{... (2 Replies)
Discussion started by: mgirinath
2 Replies

9. Shell Programming and Scripting

Shell script for Creating Directory with name as system date

Dear Sir/Madam, I need a bit of your help. The problem is as follows : I have to create a directory in unix whose name is that of system date in the dd_mon_yyyy format . I am able to extract a date in required format ina variable , but when i'm using this variable in mkdir it is not... (7 Replies)
Discussion started by: aarora_98
7 Replies

10. Shell Programming and Scripting

Creating file with date/timestamp in it

I need to create a file through a c-shell script which contains only the date and time that the file was created. Does anyone know a simple way to do this? Thank you, Paula (7 Replies)
Discussion started by: ccpjr29
7 Replies
Login or Register to Ask a Question