in reply to UNIX command - remove 0 byte file
Here's a command-line version of bart's excellent solution:
Slightly golfier is good on the command line; this is marginally shorter and calls unlink only once, on a list,src]$ mkdir empty; cd empty; touch {a,b,c}.{a,b,c} empty]$ echo foo > d.d empty]$ ls a.a a.b a.c b.a b.b b.c c.a c.b c.c d.d empty]$ perl -e'-f and !-s _ and unlink for @ARGV' *.* empty]$ ls d.d empty]$
If you don't have to worry about named pipes and other filesystem exotica, you can reduce that to,empty]$ perl -e'unlink grep -f && !-s _, @ARGV' *.*
since directories are at least one block long.empty]$ perl -e'unlink grep !-s, @ARGV' *.*
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
OT: Re^2: UNIX command - remove 0 byte file
by osunderdog (Deacon) on Sep 23, 2005 at 12:04 UTC | |
by Zaxo (Archbishop) on Sep 23, 2005 at 16:25 UTC |