Doesn't this require the file not to change too much? Take a random file bigger than 4k, and run
sed 's/./&&/g' < X 1<> X and your disk fills up! I think the request was for something like the perl "-i" which does the mv operation behind the scene. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Korn Sent: Tuesday, February 26, 2008 12:09 PM To: [email protected]; [EMAIL PROTECTED] Subject: Re: [ast-users] In-place file modification cc: [EMAIL PROTECTED] Subject: Re: [ast-users] In-place file modification -------- > Hi all, > > sometimes it would be convenient on the command line to modify files in-place, > something like the -i option in perl. Perl first renames the original > file to a temporary > name or one with a specific extension appended and then writes stdout to a new > file with the old name and the original file attributes. > > However, what I would find convenient, would be a 'delayed output operator' like > e.g. >|| that would first create an exclusive temporary (dot-)file in > the same directory > and then when all data is written [and maybe fsync()ed], it is renamed to the > actual given name and its attributes are set as expected for a new > file. Kind of like > it atomically shows up from nowhere at once after the old file is not > needed anymore, > and also nobody can access an incompletely written file by accident. > > Is there already such a mechanism that's convenient to use? > > Like that I could do > $ nl myfile | iconv -fL1 -tUTF-8 >||myfile > without having to type mv and rm. > > > Thanks, > Markus Yes, this already exists, you can do $ nl myfile | iconv -fL1 -tUTF-8 1<> myfile <> opens the file for reading and writing. The default is file descriptor is 0. tr [A-Z] [a-z] < file 1<> file David Korn [EMAIL PROTECTED] _______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users _______________________________________________ ast-users mailing list [email protected] https://mailman.research.att.com/mailman/listinfo/ast-users
