Unix Technical Forum

renaming a directory

This is a discussion on renaming a directory within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I am renaming a directory and its modification time remains the same. Is this normal? If so, is there ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2008, 02:38 PM
Peter
 
Posts: n/a
Default renaming a directory

I am renaming a directory and its modification time remains the same.
Is this normal? If so, is there any way to have it change when it is
renamed/moved?

--
Peter

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 02:38 PM
MikeDawg
 
Posts: n/a
Default Re: renaming a directory

Peter,

This is documented in man mv.

A little excerpt:

When both source and destination are on the same filesystem,
they are
the same file (just the name is changed; owner, mode, timestamps
remain
unchanged). When they are on different filesystems, the source
file is
copied and then deleted. mv will copy modification time,
access time,
user and group ID, and mode if possible. When copying user
and/or group
ID fails, the setuid and setgid bits are cleared in the copy.


You could always use touch.

mv olddir newdir; touch newdir

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 02:39 PM
Lew Pitcher
 
Posts: n/a
Default Re: renaming a directory

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter wrote:
> I am renaming a directory and its modification time remains the same.
> Is this normal?


Yes. You aren't changing the contents of the directory, so it's mtime doesn't
change.

You /are/ changing the metadata about the directory, so it's ctime will change,
as will the mtime of the parent directory (the file in which the target
directory node is recorded).

> If so, is there any way to have it change when it is renamed/moved?


Probably. But, you need to alter the contents of the directory in order to alter
it's mtime. A rename doesn't alter the contents any. P'haps touch will do.
Experiment a bit.


- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)

iD8DBQFD9NZragVFX4UWr64RAqG0AJwL9hIbl5zQ0QwFw0JLdo iJ9v1iCACgxkyE
PQ/Ivm9YH7RFjLM8lr3g6Dg=
=nZIE
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-20-2008, 02:39 PM
Peter
 
Posts: n/a
Default Re: renaming a directory

Thanks for your reply but I tested with ctime and it also does not
change after a directory move/rename:

root@marty:/vol3# ls -lhc --full-time
drwxr-xr-x 2 root root 48 2006-02-16 15:24:17.000000000 -0500
test/

root@marty:/vol3# mv test test2

root@marty:/vol3# ls -lhc --full-time
drwxr-xr-x 2 root root 48 2006-02-16 15:24:17.000000000 -0500
test2/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-20-2008, 02:39 PM
Lew Pitcher
 
Posts: n/a
Default Re: renaming a directory

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter wrote:
> Thanks for your reply but I tested with ctime and it also does not
> change after a directory move/rename:


You are correct. I realized afterword that I was wrong about the ctime. ctime
would only change if you changed the directory metadata (extended or truncated
the directory, changed it's permission bits, owner, etc.). Since this is a
rename, only the parent directory changes, so it's mtime would change. But since
a rename doesn't change the target's metadata, the target directory ctime
wouldn't change.

Sorry for the initial misinformation.

[snip]
- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)

iD8DBQFD9ONVagVFX4UWr64RApBkAKCfyfcxhRcZ86eb5bU0VV 7oxd/QhwCfXIvC
kzSszNnE4SUGLfvNV0H9QSw=
=fZqW
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:58 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com