Hacker News new | ask | show | jobs
by a_gopher 3494 days ago

  perl -E 'sub x{say;for(<$_/*>){&x;unlink}};x for@ARGV' *

  perl -E 'push@ARGV,<$_/*>for@ARGV;say,unlink for@ARGV' *
1 comments

Isn't that just "rm -rv *"? The original spec was to only delete files, not directories - and only those matching a given pattern, at that.

Also, I think yours would go into an infinite spin if it met a symlink loop (say, "ln -s . foo") - File::Find is hardened against that kinda shenanigans.

fair. not quite so pretty now...

  perl -E 'for(@ARGV){say,unlink for<$_/whatever*>;push@ARGV,($_)x(-d^-l)for<$_/*>}' .