In Unix, Sometimes when we need to take a backup of the file we generally add timestamp along with the file and create a backup, however the new file created has the creation date as system date.
This can be avoided using preserve option in unix.
For e.g. I will copy ARXSGPO.rdf from $AR_TOP/reports/US directory. The file signature looks like
-rw-r--r-- 1 applmgr oracle 647168 Apr 21 13:31 ARXSGPO.rdf
Now the following files are created using preserve and no preserve option
cp ARXSGPO.rdf ARXSGPO_np.rdf # without preserve option
cp -p ARXSGPO.rdf ARXSGPO_p.rdf # with preserve option
This is how the signature of file looks like
-rw-r--r-- 1 applmgr oracle 647168 Apr 21 13:31 ARXSGPO.rdf
-rw-r--r-- 1 applmgr oracle 647168 Apr 21 13:31 ARXSGPO_p.rdf
-rw-r--r-- 1 applmgr oracle 647168 May 3 23:43 ARXSGPO_np.rdf
It can be noted that ARXSGPO_np.rdf has timestamp as May 3, whereas file ARXSGPO_p.rdf created using preserve mode has timestamp as Apr 21. So using preserve option we can save the original information of the file from where the file is copied.
1 Comment:
Suresh this is very usefull..
Thanks.
I have a question I don't want to preserve the owner what I need to do?
Post a Comment