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

Re: Bash script problem




On 8/5/21 1:15 PM, Greg Wooledge wrote:
On Thu, Aug 05, 2021 at 01:03:16PM -0700, Gary L. Roach wrote:
First, the IFS command sets the string separator. The default values are
space /n and one other. The / is not among them.
Yes, we know that.  The issue is that you are setting IFS for the
whole script, when you probably *should* be setting it only for a
single command.
Oops. I guess I just misunderstood what you were saying. I made the change to IFS=/ read ... Works fine.
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, [...]
Why can't you just mkdir -p the final directory?  This creates the
parent directories as needed.
I've been using Debian for a long time but didn't realize you could do that. Well back to the drawing board.
[...] set chown and -x chmod. After that check the
next level and repeat the process until I run out of levels.

What do you mean by "-x chmod"?  A directory *needs* the +x permission bit
to be set in order to function properly.
Oops. The -x is a typo. S/B +x.
file=/opt/foobar/share/foobar.conf
dir=${file%/*}
mkdir -p "$dir"
touch "$file"

You're doing *way* too much work.  It's a gigantic X-Y problem.
I agree. I'm going back through the code and rewriting most of it.
I want to use this .sh file to automatically set up the Amanda backup system
I don't know Amanda, so I can't help you with that part.

That part I can work out with time. Again thanks for the help.

I'm 85 years old and the brain sometimes isn't as adgal as it used to be. The short term memory sucks.

Gary R.


Reply to: