tag:blogger.com,1999:blog-7545863793559798918.post6864591690158131129..comments2024-02-28T21:45:43.932-08:00Comments on Journal of a Programmer: Why does sort have a -o flag?Bryan Pendletonhttp://www.blogger.com/profile/01020254358854104453noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7545863793559798918.post-70637315446628985902010-01-12T13:09:09.734-08:002010-01-12T13:09:09.734-08:00Oh, old fart moment. The -o switch reduces the a...Oh, old fart moment. The -o switch reduces the amount of storage required from 3*O(N) to 2*O(N). Absent that switch the program needs to allocate O(N) for it's working copy. <br />- ben (who once got take aside for a talking to about using pipes rather than temp files on the pdp-11)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7545863793559798918.post-33876706923313845852010-01-12T11:58:05.662-08:002010-01-12T11:58:05.662-08:00Interesting question!
I can't think of many *...Interesting question!<br /><br />I can't think of many *nix utilities that produce an output file which can "replace" the original file.<br /><br />I.e. when grep'ing, cut'ing, etc. the output file contains a subset of the input, so you probably want to keep the input file. <br /><br />sort is a bit different, as (with the default options) it produces a file which in most cases (those in which the original order of the file is not "useful") can replace the original file.<br /><br />I can't think of other commands like this, except iconv (not in the traditional chain), which does provide the -o switch.Comentatorhttps://www.blogger.com/profile/00443431909508124725noreply@blogger.com