News for hackers. Stuff that matters.
Re:Ask HN: What technologies did you learn in 2018? by Zhyl on Sunday December 23, 2018 @08:10PM (#18749572)
Yeah, it has equivalents for each.

Sed:

perl -pe 's/foo/bar/' file1

Grep:

perl -pe '/foo/' file1

uniq:

perl -ne 'print unless $seen{$_}++' file1

But then you can combine conditions:

perl -ne 's/foo/bar/ if /baz/ && /yot/; print "Line number $. changed to $_"' file1

And do some awk-ish line splitting:

perl -F, -ane '$sum += $F[2]; END{ print "The sum of column 3 is $sum" }' file1

It absolutely flies in the face of the unix philosophy and is much more complicated than picking up each tool individually, but once you get to grips with 'em they're very handy.

Re:Ask HN: What technologies did you learn in 2018? by a_bonobo on Sunday December 23, 2018 @09:49PM (#18749939)
This blew my mind recently, when I had to delete millions of files in a directory and rm didn't make the cut (too many arguments), and find -delete took forever:

https://unix.stackexchange.com/a/79656

perl -e 'for(<*>){((stat)[9]<(unlink))}'

seems to be the fastest possible way to delete enormous amounts of files

Re:Ask HN: What technologies did you learn in 2018? by mkl on Monday December 24, 2018 @09:32AM (#18752273)
Did you try xargs, to do groups of files at once? That's what I usually do:

  find -type f -print0 | xargs -0 rm