Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #238240
| From | David Wright <deblis@lionunicorn.co.uk> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Bash script problem |
| Date | 2021-08-06 05:10 +0200 |
| Message-ID | <CIYpc-2Ww-9@gated-at.bofh.it> (permalink) |
| References | (2 earlier) <CIGVk-Ry-7@gated-at.bofh.it> <CIH4Z-UG-1@gated-at.bofh.it> <CIKcx-2Ph-9@gated-at.bofh.it> <CIRQJ-7vr-1@gated-at.bofh.it> <CIV7X-QV-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri 06 Aug 2021 at 09:30:17 (+1000), 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 thought that was what X is for. A demonstration:
1. Create a tree of directories and files, making them
available only to the user:
$ mkdir -p temp/tree/{a,b} temp/tree/{a/{p,q,r},b/{x,y,z}}
$ touch temp/tree/{a,b}/text temp/tree/{a/{p,q,r},b/{x,y,z}}/text
$ chmod -R go= temp/tree
$ ls -GlgR temp/tree | grep -v total
temp/tree:
drwx------ 5 4096 Aug 5 21:55 a
drwx------ 5 4096 Aug 5 21:55 b
temp/tree/a:
drwx------ 2 4096 Aug 5 21:55 p
drwx------ 2 4096 Aug 5 21:55 q
drwx------ 2 4096 Aug 5 21:55 r
-rw------- 1 0 Aug 5 21:55 text
temp/tree/a/p:
-rw------- 1 0 Aug 5 21:55 text
temp/tree/a/q:
-rw------- 1 0 Aug 5 21:55 text
temp/tree/a/r:
-rw------- 1 0 Aug 5 21:55 text
temp/tree/b:
-rw------- 1 0 Aug 5 21:55 text
drwx------ 2 4096 Aug 5 21:55 x
drwx------ 2 4096 Aug 5 21:55 y
drwx------ 2 4096 Aug 5 21:55 z
temp/tree/b/x:
-rw------- 1 0 Aug 5 21:55 text
temp/tree/b/y:
-rw------- 1 0 Aug 5 21:55 text
temp/tree/b/z:
-rw------- 1 0 Aug 5 21:55 text
$
2. Now use X to make them readable for all:
$ chmod -R a+rX temp/tree
$ ls -GlgR temp/tree | grep -v total
temp/tree:
drwxr-xr-x 5 4096 Aug 5 21:55 a
drwxr-xr-x 5 4096 Aug 5 21:55 b
temp/tree/a:
drwxr-xr-x 2 4096 Aug 5 21:55 p
drwxr-xr-x 2 4096 Aug 5 21:55 q
drwxr-xr-x 2 4096 Aug 5 21:55 r
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/a/p:
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/a/q:
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/a/r:
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/b:
-rw-r--r-- 1 0 Aug 5 21:55 text
drwxr-xr-x 2 4096 Aug 5 21:55 x
drwxr-xr-x 2 4096 Aug 5 21:55 y
drwxr-xr-x 2 4096 Aug 5 21:55 z
temp/tree/b/x:
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/b/y:
-rw-r--r-- 1 0 Aug 5 21:55 text
temp/tree/b/z:
-rw-r--r-- 1 0 Aug 5 21:55 text
$
All the directories get execute permission.
Cheers,
David.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bash script problem "Gary L. Roach" <garyroach719@gmail.com> - 2021-08-05 02:00 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-05 02:10 +0200
Re: Bash script problem "Gary L. Roach" <garyroach719@gmail.com> - 2021-08-05 05:50 +0200
Re: Bash script problem john doe <johndoe65534@mail.com> - 2021-08-05 09:00 +0200
Re: Bash script problem <tomas@tuxteam.de> - 2021-08-05 10:10 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-05 13:20 +0200
test vs. [ [was: Bash script problem] <tomas@tuxteam.de> - 2021-08-05 14:00 +0200
Re: test vs. [ [was: Bash script problem] Greg Wooledge <greg@wooledge.org> - 2021-08-05 14:40 +0200
Re: test vs. [ [was: Bash script problem] <tomas@tuxteam.de> - 2021-08-05 15:00 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-05 14:30 +0200
Re: Bash script problem Anssi Saari <as@sci.fi> - 2021-08-05 09:40 +0200
Re: Bash script problem Tixy <tixy@yxit.co.uk> - 2021-08-05 10:30 +0200
Re: Bash script problem <tomas@tuxteam.de> - 2021-08-05 10:40 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-05 14:00 +0200
Re: Bash script problem "Gary L. Roach" <garyroach719@gmail.com> - 2021-08-05 22:10 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-05 22:20 +0200
Re: Bash script problem "Gary L. Roach" <garyroach719@gmail.com> - 2021-08-06 17:00 +0200
Re: Bash script problem <tomas@tuxteam.de> - 2021-08-06 17:10 +0200
Re: Bash script problem David <bouncingcats@gmail.com> - 2021-08-06 01:40 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-06 02:10 +0200
Re: Bash script problem Polyna-Maude Racicot-Summerside <debian@polynamaude.com> - 2021-08-06 02:20 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-06 02:30 +0200
Re: Bash script problem The Wanderer <wanderer@fastmail.fm> - 2021-08-06 03:50 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-06 04:10 +0200
Re: Bash script problem Polyna-Maude Racicot-Summerside <debian@polynamaude.com> - 2021-08-06 02:10 +0200
Re: Bash script problem Christian Groessler <chris@groessler.org> - 2021-08-06 02:30 +0200
Re: Bash script problem Christian Groessler <chris@groessler.org> - 2021-08-06 03:00 +0200
Re: Bash script problem Greg Wooledge <greg@wooledge.org> - 2021-08-06 03:10 +0200
Re: Bash script problem David <bouncingcats@gmail.com> - 2021-08-06 03:10 +0200
Re: Bash script problem David <bouncingcats@gmail.com> - 2021-08-06 03:00 +0200
Re: Bash script problem <tomas@tuxteam.de> - 2021-08-06 09:00 +0200
Re: Bash script problem David Wright <deblis@lionunicorn.co.uk> - 2021-08-06 05:10 +0200
Re: Bash script problem David <bouncingcats@gmail.com> - 2021-08-06 05:50 +0200
Re: Bash script problem Darac Marjal <mailinglist@darac.org.uk> - 2021-08-06 09:20 +0200
Re: Bash script problem Tom Browder <tom.browder@gmail.com> - 2021-08-06 01:00 +0200
csiph-web