How to retain "directory" timestamp when using gzip?

Hello All,

I am trying to gzip a directory contents with the option "-r". The file timestamps remaining same but not the directory, how to retain it too.

ex:

 
$ ls -l 20090624065000
total 1213360
-rwxrwxrwx   1 cisa       users      529513119 Jun 24  2009 A
-rwxrwxrwx   1 cisa       users      65014911 Jun 24  2009 B
 
$ls -lrt | grep 20090624065000
drwxrwxrwx   2 cisa       users         2048 Jun 24  2009 20090624065000

once I do gzip, the file timestamps remaining same but the directory
timestamps are getting changed , had a look at man but no clue!.

 
 
$ gzip -r 20090624065000
total 1213360
-rwxrwxrwx   1 cisa       users      3230030 Jun 24  2009 A.gz
-rwxrwxrwx   1 cisa       users      232903 Jun 24  2009 B.gz
 
$ls -lrt | grep 20090624065000
drwxrwxrwx   2 cisa       users   2048 2048 Mar 31 12:06 20090624065000

Because you changed the contents of that directory. So it gets a new timestamp being displayed; normal behaviour.

man gzip:

       -r --recursive
              Travel the directory structure recursively. If any of the file names specified on the command line are  directories,  gzip  will  descend
              into the directory and compress all the files it finds there (or decompress them in the case of gunzip ).

If you want to compress the directory too with all it's contents together and sowith preserve the timestamp on the directory too, you'd rather use something like:

tar cvzf 20090624065000.tgz 20090624065000

or if z is not supported with your tar, try:

tar cvf 20090624065000.tar 20090624065000
gzip 20090624065000.tar

Thanks zaxxon,

I understood we can do that using "tar". But I was wondering if there is any option which "hides" the changes made to files ; so the directory timestamp remains as it is when using "gzip".

Cheers
Ravi