Article 4XA3S Bash MKDIR automation script

Bash MKDIR automation script

by
TBotNik
from LinuxQuestions.org on (#4XA3S)
All,

Writing a svript to automate parst of the mkdir process:
Code:#! /bin/bash
# Script to set default permissions to a directory

downr="$USER:users"; # Assign Default users
dir=$1;
if [ -d "$dir" ] then
echo "Directory exists, only ownership and permissions will be changed!"
else
mkdir -P $dir
echo "directory $dir created!"
fi
chown -R $downr $dir;
defpm="775" # Set Directory permissions
dperm < ls -ld $dir
prm=$2;
if [ ] then
chmod -R $rwpms $dir;
fiI'm good to line 14 where I have the cmd:
Code:ls -ld directorwhich produces:
Code:drwxrwxr-x 35 $USER users 4096 Feb 16 2019 $dirWhat I need is the numeric permissions and the "owner:group" for my "IF" statements so I can make sure I have both the fight ownership and permissions comparing both the default value of $prm and $defpm to what the system says the permissions are.

I'm guessing I either need a different cmd other than ls -ld $dir or a way to process out the data it produces.

All help appreciated!

cheers!

TBNKlatest?d=yIl2AUoC8zA latest?i=TXvok3hxp4M:_gCHjR4n-XM:F7zBnMy latest?i=TXvok3hxp4M:_gCHjR4n-XM:V_sGLiP latest?d=qj6IDK7rITs latest?i=TXvok3hxp4M:_gCHjR4n-XM:gIN9vFwTXvok3hxp4M
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments