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

Quote:
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:
Code:
$ cat file
1
3
4

$ awk 'NR==2{$0=$0" 2"}1' file
1
3 2
4
__________________
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