On Tue, 31 Jul 2001, Linux @ Ramshyam wrote:
While doing Shell Scripting, If i need to alter/delete a line or a part there-of, is there any direct way, or do I wite all the contents into a new file, ignoring the "to-be-deleted" line / write the modified line....
This is not a shell script problem, but a standard file IO problem (when I say problem I mean the kind that you get at the end of a chapter in a text book). The only way to do it is to transfer everything to a new file, ignoring what is to be delted.
Editing however is easy to do in a single file if you use fixed length records. Just overwrite from the correct place with the exact number of bytes. Remember that you cannot insert into a file, only append or overwrite.
Philip