Copy a file with name as date??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copy a file with name as date??
# 1  
Old 10-09-2006
Copy a file with name as date??

Hi I want to copy a file but append the date and time....how?

So copying the file file1.txt will have file1_20061009_0950.txt

I know the command :
date +"%Y%m%d_%H%M"

but how do i get this in the file name ?
cp file1.txt newDirectory/file1_?????????.txt

Thanx
# 2  
Old 10-09-2006
Did you try this

Code:
cp file1.txt newDirectory/file1_`date +"%Y%m%d_%H%M"`.txt

# 3  
Old 10-09-2006
ahhhhhhhhhhh, i rem seeing something like that before:P

Thanks mate!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find and copy .zip file based on today's date

Hi Team, I'm new to unix and i have a requirement to copy or move files from one directory to another based on current date mentioned in the .zip file name. Note that i need to copy only the recent zip file. please help me with the code i tried the code as: #! /usr/bin/sh find... (3 Replies)
Discussion started by: midhun3108
3 Replies

2. Shell Programming and Scripting

Script to copy creation date over top of modified date?

Can someone draw up a script that for every file, folder and subfolder and files that will copy the creation date over top of the modified date?? I know how to touch every file recursively, but no idea how to read a files creation date then use that to touch the modification date of that file,... (3 Replies)
Discussion started by: toysareforboys
3 Replies

3. Shell Programming and Scripting

File Copy based on file receive date

I have bunch of files in my source folder like below and every day based on date I am receiving file ex: Nov 28,Nov 29,Nov 30 ... -rw-rw-r--+ 1 root root 20 Nov 27 06:00 aaaa27.txt -rw-rw-r--+ 1 root root 20 Nov 28 06:00 aaaa28.txt -rw-rw-r--+ 1 root root 20 Nov 29 06:00 aaaa29.txt I... (4 Replies)
Discussion started by: krish2014
4 Replies

4. UNIX for Dummies Questions & Answers

Copy log based on from-date and to-date

Hi all, i go a customer support requirement where i need to scan several files based on from/to date like 1-oct to 2-oct please help... (3 Replies)
Discussion started by: AbhiJ
3 Replies

5. Shell Programming and Scripting

grep date with copy command

how can i copy only those files with creation date less then 24 hours. (1 Reply)
Discussion started by: Danish Shakil
1 Replies

6. Shell Programming and Scripting

Copy files based on date

Hi all i am having so many files in my directory.Is there any option to copy files based on date. example i am having file this -rw-rw-r-- 1 ram user 1 Feb 2 17:12 abc -rw-rw-r-- 1 ram user 1 Feb 2 17:12 bnw -rwxrwxr-x 1 ram user 21122 Feb 4... (3 Replies)
Discussion started by: suryanarayana
3 Replies

7. Shell Programming and Scripting

copy/rename file as date() unix/shell

File.jpg I want to copy and rename this as 2008-12-02.jpg I tried this copy File.jpg date '%y-%m-%d-%H:%M:%S'.jpg This doesnt work.... what do i do? (1 Reply)
Discussion started by: hdogg
1 Replies

8. Shell Programming and Scripting

How to copy a file according to the date

Hi, I want to copy a some files according to the date. lets say i want to copy file from june1st to june14th. What is the command for that ? Thanks, Nayanajith. (1 Reply)
Discussion started by: Nayanajith
1 Replies

9. HP-UX

copy files with date

Hi, I have a coupel of files in /tmp which I have to copy to /var. But I want their name to be same as the source with date suffix. But the problem is I don;t know the prefix of the file, I only know the suffix of file. AAA.997 ABC.997 ADC.997 The later part 997 is constant but the... (1 Reply)
Discussion started by: isingh786
1 Replies

10. UNIX for Dummies Questions & Answers

ftp copy: preserve source file date stamp

Is there any way to preserve a file's create/mod date stamp when it is "put" via ftp (or even using Fetch) to a Win2K server and a SunOS 5.8 server? For example, if I copy a file with a create/mod date of "01/15/2005 3:36 PM" to my Win2K or SunOS ftp server, the date stamp will change to the... (5 Replies)
Discussion started by: cassj
5 Replies
Login or Register to Ask a Question