From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: Ralph Corderoy Message-ID: <3828.3f264674.96335@blake.inputplus.co.uk> References: <1064.3f2242e3.bedc3@blake.inputplus.co.uk>, <4e9a248eadf51083ac5d918159014eda@collyer.net> Subject: Re: [9fans] text utility Date: Wed, 30 Jul 2003 08:25:46 +0000 Topicbox-Message-UUID: 0a5a96bc-eacc-11e9-9e20-41e7f4b1d025 Hi Geoff, > One could use "pr -tn" instead of the little awk script, but the > difference in speed really isn't that great. Reading a cached ~2.5MB > file of ~250K lines, > > cpu% time awk '{print NR, $0}' test >/dev/null > 2.85u 0.13s 3.53r awk {print NR, $0} test > cpu% time pr -tn test >/dev/null > 1.75u 0.13s 2.18r pr -tn test Fair enough. Under AIX and Linux cat's a win. Using yes(1) so awk's little work to do: $ yes y | head -n 250000 | time awk '{print NR, $0}' >/dev/null real 1.13 user 1.06 sys 0.01 $ yes y | head -n 250000 | time cat -n >/dev/null real 0.08 user 0.05 sys 0.00 I used it heavily when doing ad-hoc queries on files with millions of lines. But, like you say, if it's not present, it's no use. Cheers, -- Ralph Corderoy. http://inputplus.co.uk/ralph/ http://troff.org/