[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Checking if directory is empty in postrm



Marcus Brinkmann wrote:
> can someone give me a hint how I can efficient test if a certain directory
> is empty in the postrm (shell script)?

If you only want to know if it's empty because you want to remove it,
then there's a very simple solution:

rmdir directory 2>/dev/null || true

The rmdir will fail if it's not empty :)
(You can use its return code if you need to check if it succeeded)

Richard Braakman


Reply to: