[PLUG] One-liners

Jameson Williams jameson at jamesonwilliams.com
Wed Jul 29 00:37:55 UTC 2009


Or how about find . -empty -maxdepth 1 -delete



On Tue, Jul 28, 2009 at 5:35 PM, Jameson Williams <
jameson at jamesonwilliams.com> wrote:

> On Tue, Jul 28, 2009 at 5:14 PM, Andrew Brookins <a.m.brookins at gmail.com>wrote:
>
>> Hey, list,
>>
>> This is kind of a pedestrian request, but hey, it's like 104 degrees
>> outside.
>>
>> I wanted to remove all empty files in a directory today, so I typed
>> this command:
>>
>>  ls -s | grep -e '^ 0' | sed 's/^...//' | xargs -n1 rm -v
>>
>> Then I was like, WTF, three pipes?  And I wondered how many variations
>> on this kind of thing there were.  There's also this one, which I just
>> pulled from http://www.linux.ie/newusers/beginners-linux-guide/find.php:
>>
>>  find . -empty -maxdepth 1 -exec rm {} \;
>>
>>  But maybe you have a better one?  Or if not, maybe you can share your
>> favorite one-liner?
>>
>> Andrew
>> _______________________________________________
>> PLUG mailing list
>> PLUG at lists.pdxlinux.org
>> http://lists.pdxlinux.org/mailman/listinfo/plug
>>
>
> Andrew, I like your find command -- that's the most concise I can think of.
> find, ssh, xargs, and the bash <<< redirect are all good for making concise
> and powerful one-liners.
>
> Here's another version of yours, though doesn't hit the hidden stuff:
>
> find * -prune -empty -exec rm {}\;
>
>
>



More information about the PLUG mailing list