mv folders/files without changing modified date?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers mv folders/files without changing modified date?
# 1  
Old 09-27-2010
Question mv folders/files without changing modified date?

Hi all,

I'm using Red Hat Linux and want to move some folders and files around but not change the modified date. Is this possible?

I know cp has a -p flag which seems to do what I want, but this is a large volume of data so copying and deleting would not be feasible.
# 2  
Old 09-27-2010
Are they on the same filesystem ? If they are I was under the impression "mv" would work fine, if they arent then "cp" followed by "rm" is just as effective anyway.
# 3  
Old 09-27-2010
They are on the same file system. mv does not preserve modified date but stamps it as now.

I could do a copy and delete, but like I said this is a large volume of data so copy/delete would take a lot of time. If I have to I can do that, but I'm surprised there is no way to move files and preserve their modified date. I've looked and haven't found anything.
# 4  
Old 09-27-2010
Ah, are you talking the modification time, or the change time of the file ?
My modification date stays the same, but my change time changes:
Code:
> ls -l try2.c
-rw-r--r-- 1 ctaylor users 2162 2010-07-01 09:51 try2.c
> ls -ltc try2.c
-rw-r--r-- 1 ctaylor users 2162 2010-07-01 09:51 try2.c
> mv try2.c foo
> ls -l foo
-rw-r--r-- 1 ctaylor users 2162 2010-07-01 09:51 foo
> ls -ltc foo
-rw-r--r-- 1 ctaylor users 2162 2010-09-27 15:28 foo

# 5  
Old 09-27-2010
I'm sorry for not being clear. I didn't realize there were 2 dates. Smilie

The date I mean is indeed the date in "ls -l" and also the "Last Modified" date that appears in FTP programs like Filezilla.
# 6  
Old 09-27-2010
Ive just tried it on my rhel 5 box, and I get the same results. "mv" doesnt update my modified time. Can you do a similar test to my one above and show me your results ?
Thx.
# 7  
Old 09-27-2010
Thanks for that - from that experiment it seems that files moved with "mv" do get stamped their original modified time but folders do not. I'm assuming this is because Unix has to recreate the folder new, hence why the new timestamp.

So I guess now the question is - is there a way to move folders and preserve the modify timestamp?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changing CSV files with date . Subtracting date by values

Hi All, I have a CSV file which is as below. Basically I need to take the year column in it and find if the year is >= 20152 . If that is then I should subtract all values by 6. In the below example in description I am having number mentioned as YYWW so I need to subtract those by -5. Whereever... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

2. UNIX for Dummies Questions & Answers

Changing cases of multiple files in different folders

I am a TA for a computer science course and we have a program that flags code that appears to the same as other code that is supplied. In order for the program to check all of the student's programs, the programs all need to be named exactly the same. However, students don't like to follow... (12 Replies)
Discussion started by: bpmawhin
12 Replies

3. Shell Programming and Scripting

How to get the files which has modified date as yesterday and before?

Hi All, Can you please help me to get only the files which has the modified date as yesterday and before? Thanks in advance! Regards, Velava.S (4 Replies)
Discussion started by: velava
4 Replies

4. Emergency UNIX and Linux Support

Is there any way to set the files modified date and stamp to last modifies time?

Actually i did modification in a file on server by mistake, now its showing current time stamp, is there any way to set the files modified date and stamp to last modifies time. Please advice here.Thanks in advance.:b: (7 Replies)
Discussion started by: saluja.deepak
7 Replies

5. Shell Programming and Scripting

FTP files modified after a particular date between servers

Hi all, i need to write a shell script to transfer a file modified after a particular date from one server to another. I searched for the related posts in this forum and got hints and snippets for it. i tried the below code ftp serverA user uname pwd lcd to_dir cd from_dir files=$(find... (7 Replies)
Discussion started by: mick_000
7 Replies

6. UNIX for Dummies Questions & Answers

Number of files in a directory modified on a date

Hi How to list all the files in a directory that are modified on a particular date? Also need to know the count,i.e number of files modified on a particular date. Thanks Ashok (1 Reply)
Discussion started by: ashok.k
1 Replies

7. UNIX for Dummies Questions & Answers

Find last modified date for many files

Hello all - I've looked and have not been able to find a "find" command that will list the last modified date of files within a specific directory and its subdirectories. If anyone knows of such a command it would be very much appreciated! If possible, I would like to sort this output and have... (5 Replies)
Discussion started by: MichaelH3947
5 Replies

8. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies

9. Linux

compare files in the system with last modified date

HI, I have some files in my Linux machine that are very old and occupy a HUGe amount of space. I am trying to delete these files from the system so that it will be easy for me to add some files. I would like to know if this can done through a Perl or a shell script. What i want to do is i... (6 Replies)
Discussion started by: bsandeep_80
6 Replies

10. Shell Programming and Scripting

List Files & Folders created/modified

Hello people, I want to list the files & folders created/modified since a particular date say June 2006. I know I can list recursively thru the folders and use awk to extract the date column to get the desired output. Just wanted to check whether there is an easier way to do this. Please... (2 Replies)
Discussion started by: tipsy
2 Replies
Login or Register to Ask a Question