#!/bin/sh # arguments: path ... # works on the current directory if no path was given. nargs() { while read line do "$@" "$line" done } find "$@" -depth -type f -size 0 | nargs unlink find "$@" -depth -type d | nargs rmdir 2> /dev/null