I'm pretty new to scripting and trying to do a simple (well, I thought so) administrator task. I'm using bash.
I want to create 10 directories under the one directory and apply permissions at the same time.
I've worked out the make directories part:
Can I apply permissions to each directory at the same time as creation? And can I also add more arguments such as creating another directory under only specific directories?
Thanks.
Last edited by Don Cragun; 08-10-2014 at 01:09 AM..
Reason: Please use CODE and ICODE tags.
I'm pretty new to scripting and trying to do a simple (well, I thought so) administrator task. I'm using bash.
I want to create 10 directories under the one directory and apply permissions at the same time.
I've worked out the make directories part:
Can I apply permissions to each directory at the same time as creation? And can I also add more arguments such as creating another directory under only specific directories?
Thanks.
If you want to create multiple levels of directories and you want to exactly specify the mode of all the directories being created, don't use the -p option to create subdirectories; instead use the -m mode option where the mode option-argument specifies the mode you want all of the newly created directories to have and specify all of the directories that need to be created as operands. The mode option-argument can be in any of the formats used when specifying a mode for the chmod utility. (Just be sure to give the paths of parent directories as operands before any subdirectories that you want to create in those parent directories. And, note that if you specify a mode that doesn't include write mode for the owner class, attempts to create subdirectories will fail.)
Note that you said you wanted to create 10 directories, but:
will create 52 directories; not 12 (with permissions on all of them set to allow read, write, and search by the user and group classes with no access by the other class).
Last edited by Don Cragun; 08-10-2014 at 07:31 AM..
Reason: Corrrect subdirectory pathnames.
I'm using CentOS but want to stick to bash as I'm still learning and want to stick to the same shell for now. I'm reading up on scripts and I'm thinking using a if, else type script - just not sure how to make it work exactly.
Importing images from a camera (or two).
I sort by date (1901 this month).
Currently (failing)
if ]
then
echo "Found Panasonic G9X"
#echo "List files on camera"
#ls ${pana}/*
. chxdir.sh ${photos}/$mn
I want to change directory to a fixed base ($photos)/$mn... (10 Replies)
I have a file with lines like:
111 12 7
111 13 8
112 12 9
115 31 3
120 31 9
123 10 7
125 12
I want to make a script which, split the first column into parts (101-110, 111-120...), and make directories for its part with name (101-110, 111-120...) Also i want in every directory include... (7 Replies)
Hello, :)
I've an issue with the creation of a directory, All work without it :mad: So, below, my scripts with the debug output :
#!/bin/bash
# PATHS
HOME_BACKUP="/home/backup"
HOME_SCRIPT="/home/scripts/test/backup_server"
TARGET="/var/www"
# DATE
DATE_Ymd=$(date +%Y-%m-%d)
#... (1 Reply)
Hi
I have written the following script that later I want to put in cron,:
#!/bin/bash
_find="/usr/bin/find"
_paths="/moneta_polled01/mediation_gsm /moneta_polled01/mediation_mmsc"
for d in $_paths
do
$_find $d -type f -exec chmod 777 {} \;
done
but it does not seem to be... (8 Replies)
I have a script were I issue the following command:
perl -p -i -e "s/$v31a/$db2/" $dbn31
My script fails with permission error. However, at the command line I can edit the directory in question. I am using uname 002 in my script. So, why can i update manually but not in a script? (10 Replies)
Hi there,
I've been having some frustrating problems with a permissions script. Basically I want it to to determine what permissions the owner, group and everybody has for the file passed in.
Here's what I've got:
#!bin/bash
echo -n "Enter filename: "
read file
owner=$( ls -l $file | cut... (7 Replies)
Hi,
I wanted to know how to create a folder using mkdir and then have it copy the permissions from another specified folder on the system.
For example if I did this:
mkdir /Volumes/USBSTICK/System
How can I make it copy the permissions from the /System folder ?
Thanks (4 Replies)
I am having a problem getting this to work right. The script needs to search through directories and subdirectories. If a jpg is found then create a folder in that directory, so on and so forth. Here is what I have so far but it doesn't work right. Help please
#!/bin/bash
for d in `find ./... (1 Reply)
Hi
I have this code, and i want work with a ls -shalR output in .txt
What i need read to do this??
Where start?
#!/usr/bin/perl
# Allrights- A perl tool for making backups of file permissions
# Copyright (C) 2005 Norbert Klein <norbert@acodedb.com>
# This program is free... (1 Reply)
Hi,
I'm trying to execute a shell script from application (Informatica). The script works fine when I execute it from command line but fails when executed from Informatica. The tricky part is that there is other scripts in the same folder that can be executed succesfully from both command line... (1 Reply)