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

Re: Bash script problem



On 06/08/2021 00:30, David wrote:
> On Fri, 6 Aug 2021 at 06:03, Gary L. Roach <garyroach719@gmail.com> wrote:
>
>> Second, why am I separating out the Path the way I am doing? I need to
>> check each level for existence then, if the level doesn't exist, create
>> the directory, cd to the directory, set chown and -x chmod. After that
>> check the next level and repeat the process until I run out of levels.
>> There are other things that need to be done with files that are similar.
> It sounds like you are unaware of 'mkdir -p' and 'chown -R'.
> They are the standard tools for this kind of task.
>
> 'chmod -R' is less useful because it does not discriminate
> between files and directories, I never understood why it
> does not offer that option, because usually we need all file
> permissions to not be the same as all directory permissions.

I also recently discovered that 'mkdir' has a '-m, --mode' option so
that, depending on your use case, you might not even need chmod. 'mkdir
-m u=rwx,g=rx,o= -p /path/to/somewhere' for example.

>

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: