![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to extract date with time from file | prash_b | Shell Programming and Scripting | 5 | 06-18-2008 05:30 AM |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 08:23 AM |
| Date and time log file | captoro | Shell Programming and Scripting | 8 | 09-03-2007 06:23 PM |
| file creation date & time | alisevA3 | UNIX for Dummies Questions & Answers | 3 | 07-08-2005 02:21 AM |
| File date and time stamp | Xenon | UNIX for Dummies Questions & Answers | 1 | 10-09-2001 12:58 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do I put a date and time in a file name
I want to copy a file to another file so that the current time and date are in the file name. For example I want to copy file profit.txt to a file name in the format
of profit_YYYYMMDDHHmm.txt where YYYY is year, MM is number of the month DD is the number of day of the month, HH is the hour of the day, and mm is the minute in the hour. for example, profit_200701130830.txt would mean the file was created on Jan 13, 2007 at 8:30am. i know how to copy to a file name in format of YYYYMMDD, but i also need the time. see below #!/usr/bin/ksh DTSTAMP=$(date "+%Y%m%d") cp /fdb/prod/fdbadm/data/profit.txt /fdb/prod/fdbadm/data/profit_$DTSTAMP.txt |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Add %H & %M
crypto $ date Sat Jan 13 09:36:39 PST 2007 crypto $ date "+%Y%m%d%H%M" 200701130936 |
|
#3
|
|||
|
|||
|
thanks for the quick response
|
|||
| Google The UNIX and Linux Forums |