Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to edit some file in my linux for example

ls -ltr /etc/some_file

-rw-r--r-- 1 root root 188 Jul  1  2010 sysstat


       echo "Server101_IP=" >> /etc/some_file


I expect to get the following date:

 ls -ltr /etc/some_file

-rw-r--r-- 1 root root 188 Jul  1  2010 sysstat

but the date & time of this file must be not change !

I just want to edit file but I Wondering how to change the file without effect on the date & time of the file - is it possible ?

share|improve this question

closed as not constructive by EEAA, Tom O'Connor, Tim Brigham, Ward, Magellan Dec 3 '12 at 7:02

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

One question: why? – EEAA Dec 2 '12 at 21:26
because I build some script that search the IP - in all Linux directories but this script ignore if file is old then the OS creation - that the reason , so I want to test my script and see if it really ignore the old files – yael Dec 2 '12 at 21:35

You could do something with stat to get the file's Access, Modify and Change timestamps and then after editing the file you can use touch to set the relevant times back to what they were originally.

share|improve this answer
@LAIN please give me exaample – yael Dec 2 '12 at 21:40
@yael Tis not a "gimmeh teh c0dez" site - It is a resource for professionals who want to further their knowledge while solving a problem. Read the manual pages that Iain was good enough to link to, learn about the tools, and apply them to your situation. – voretaq7 Dec 3 '12 at 3:15
simple solution that I find: touch -t 200805101024 /etc/filename – yael Dec 5 '12 at 13:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.