News for hackers. Stuff that matters.
Re:Top Unix Command Line Utilities by niggler on Sunday December 30, 2012 @09:22AM (#4985740)
Where's the love for awk? It has been tucked away in a sub item but doesn't deserve first class status?
Re:Top Unix Command Line Utilities by imglorp on Sunday December 30, 2012 @09:35AM (#4985769)
That whole "find -ls | awk" is wicked slow anyway; try wc and xargs...

  $ time find -ls | awk '{s += $7} END {print s}'
  15970582120

  real	0m27.721s
  user	0m1.256s
  sys	0m1.780s

  $ time find | xargs wc -c 2> /dev/null | tail -1
  604260969 total

  real	0m0.332s
  user	0m0.068s
  sys	0m0.204s
Re:Top Unix Command Line Utilities by dbaupp on Sunday December 30, 2012 @10:57AM (#4986026)
The standard disclaimer on find | xargs: you should use -print0 and -0 to avoid problems with files with whitespace in their names, i.e.

   $ find -print0 | xargs -0 wc -c 2> /dev/null | tail -1
(Also, many uses of find | xargs can be replaced with -exec cmd {} \; or -exec cmd {} +, e.g.

  $ find -exec wc -c {} + 2> /dev/null | tail -1
although this isn't much faster in this case.)
Re:Top Unix Command Line Utilities by aidos on Sunday December 30, 2012 @11:04AM (#4986058)
You sure that's not because of memory swapping? Once warmed up the awk command is much faster for me.

Also, the results are different - though I'm too lazy to figure out why right now :)

Re:Top Unix Command Line Utilities by cynwoody on Sunday December 30, 2012 @02:03PM (#4986731)
You need to filter out directory entries.

    find -type f -ls|awk '{s += $7} END {print s}'
    find -type f -print0 | xargs -0 wc -c | tail -1
    find -type f -exec wc -c {} + | tail -1
Re:Top Unix Command Line Utilities by zxcdw on Sunday December 30, 2012 @11:04AM (#4986054)
I am not familiar with awk, what's the 's+= $7'? What is the argument 2 passed to wc? Why is the produced output different? What am I missing here?
Re:Top Unix Command Line Utilities by coldgrnd on Sunday December 30, 2012 @11:17AM (#4986109)
s += $7 means "add the content of the 7th column to the total"
Re:Top Unix Command Line Utilities by zxcdw on Sunday December 30, 2012 @01:55PM (#4986696)
Makes sense, thanks!
Re:Top Unix Command Line Utilities by prostoalex on Sunday December 30, 2012 @05:27PM (#4987375)
2013 will be the year of awk on the desktop.
Re:Top Unix Command Line Utilities by coldgrnd on Sunday December 30, 2012 @11:06AM (#4986071)
actually there is heaps of love for awk... so much actually that I'd rather spend a whole post on it than to "just" make it one item :)
Re:Top Unix Command Line Utilities by niggler on Monday December 31, 2012 @10:23AM (#4989527)
Motivated by your list, I went through my history to pull some awk snowclones http://news.ycombinator.com/item?id=4989524