View Single Post
Old 8th November 2010
s0xxx's Avatar
s0xxx s0xxx is offline
Package Pilot
Join Date: May 2008
Posts: 192

Originally Posted by drl View Post
My take on this is that the in-place options on most utilities are something of a misnomer. The data is written to a scratch file, then copied back onto the original -- one does not get something for nothing. This is true of "-i" on GNU sed, as well as the interactive editors ed/ex. So that the in-place description refers to the result rather than the method.
I fully agree.

Anotha' (similar) awk solution:
$ cat file

$ awk 'NR==2{$0=$0" 2"}1' file
3 2
The best way to learn UNIX is to play with it, and the harder you play, the more you learn.
If you play hard enough, you'll break something for sure, and having to fix a badly broken system is arguably the fastest way of all to learn. -Michael Lucas, AbsoluteBSD
Reply With Quote