[K12OSN] OT: bash scripting - check for permissions, check for existence of file in directory tree

Rob Owens rob.owens at biochemfluidics.com
Wed Sep 24 11:17:58 UTC 2008

Nils Breunese wrote:
> Rob Owens wrote:
>> I know there are a lot of seasoned bash scripters on this list, so here
>> goes.
>> 1) I need to check if the user running the script has sufficient
>> permissions to write to a certain directory.
> ----
> if [ -w directory ]
> then
>     <do some stuff>
> fi
> ----
Thanks, just what I needed.

>> 2) I need to check for the existence of a file somewhere in a directory
>> tree (with lots of subdirectories).
> ----
> find <directory> -name <filename>
> ----
I thought of that, but suspected there might be a better way.  Guess I
was wrong.  Thanks for helping.


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you are not the addressee, any disclosure, reproduction,
copying, distribution, or other dissemination or use of this transmission in
error please notify the sender immediately and then delete this e-mail.
E-mail transmission cannot be guaranteed to be secure or error free as
information could be intercepted, corrupted lost, destroyed, arrive late or
incomplete, or contain viruses.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission. If verification is required please request a hard copy


More information about the K12OSN mailing list