Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Preserving timestamp with -i switch

by umasuresh (Hermit)
on Sep 19, 2011 at 19:10 UTC ( [id://926794]=perlquestion: print w/replies, xml ) Need Help??

umasuresh has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
Is there a way to preserve the timestamp while backing up a file using the  -i switch?
e.g.
perl -e 's/old/new/g;' -pi.bak somefile
UPDATE Got it, thanks!
By default, this command preserves the timestamp!

Replies are listed 'Best First'.
Re: Preserving timestamp with -i switch
by AR (Friar) on Sep 19, 2011 at 19:29 UTC

    Please post what you found, so others searching for the same problem can learn from your solution.

Re: Preserving timestamp with -i switch
by duyet (Friar) on Sep 20, 2011 at 06:07 UTC

    Use -p option in cp to preserve mode, ownership, timestamp

    for i in `find . -type f -print`; do cp -p $i ${i}_bk;done

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://926794]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-16 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found