in reply to Help in read and write to file at a same time in same file.
I want to read and write in file at a time (Is it possible ?)
Yes it is possible (check out "+<" and "+>>" file modes for open) but in your case it's a terrible idea.
Why? Because your output is longer than your input. As a result, you will be overwriting the data before you got a chance to read it.
-i emulates rewriting a file, but actually it's writing to a new file, and the new file replaces the old file when it's finished. On Linux you can notice the difference because the file permissions and/or ownership may end up different from what you started from.
|
|---|