Edit file without changing the timestamp

edit-notime () { FILE=$1; TMP=`mktemp /tmp/file-XXXXXX`; cp -p $FILE $TMP; $EDITOR $TMP; touch -r $FILE $TMP; cp -p $TMP $FILE; rm -f $TMP; }
Copies file to a temporary location, edit and set to real file's time stamp then copy back. Assumes access to /tmp and has $EDITOR, but can be replaced with better values.

2012-10-31 00:54:19

What Others Think

We can edit the time that are mentioned in it with the help of time stamp or with the help of java codes. By the use of dissertation company we will manage the codes of JavaScript.
pageloqe · 70 weeks and 4 days ago
Hey everyone, this is the fourth article in the series on the most popular commandlinefu one-liners explained. Here are the first three part ... by epicfollowerscanada
Buyinstagarm · 68 weeks and 2 days ago
Whether you're an veteran system admin or a command-line neophyte striving to discover more, CommandLineFu is a vote-driven collection of ... by buyinstagramfollowerscanada
Buyinstagarm · 68 weeks and 2 days ago
Here's how to change file attributes on Windows 10 using these ... you to change the created, modified, and accessed timestamps—change ... by buy instagram followers uk
buyfollowersuk · 67 weeks and 6 days ago
Renaming the file doesn't change the modification time stamp. Neither does opening the file without making any changes to it. Time/Date ... by http://followersuk.co.uk/"> buy real instagram followers uk
buyfollowersuk · 67 weeks and 6 days ago
NAME. Image::ExifTool::Shift.pl - ExifTool time shifting routines. DESCRIPTION. This module contains routines used by ExifTool to shift date and time values. [url=https://buyfollowersaustralia.com.au/] buy instagram followers [/url]
followerscanda9 · 67 weeks and 4 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: