Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 1
    Can confirm. I use mikeserv's initial example in scripts I've written. Commented May 8, 2015 at 21:05
  • 1
    That would report as empty directories that don't exist or for which you don't have read access. For the second one, if you have read access but not search access, YMMV. Commented May 20, 2015 at 12:23
  • @StéphaneChazelas - perhaps, but such reports will be accompanied by error messages to notify the user of such. Commented May 20, 2015 at 13:28
  • 1
    Only in the ls case. globs and [ are silent when they don't have access. For instance, [ -e /var/spool/cron/crontabs/stephane ] will silently report false, while there is a file by that name. Commented May 20, 2015 at 13:47
  • 1
    @progonkpa if you added a !bang before echo false your return value would reflect your exit status. Commented Sep 24, 2023 at 2:33