Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script for mkdir with permissions Post 302912572 by jimothy007 on Saturday 9th of August 2014 11:26:09 PM
Old 08-10-2014
Script for mkdir with permissions

Hello,

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:
Code:
mkdir  /userdata/folder{1..50}

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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script permissions

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)
Discussion started by: tmikahan
1 Replies

2. Shell Programming and Scripting

Modify Perl script to work with txt - Permissions script

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)
Discussion started by: joangopan
1 Replies

3. Shell Programming and Scripting

find jpg's mkdir script help

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)
Discussion started by: jedhypes
1 Replies

4. Shell Programming and Scripting

mkdir: copying a folder's permissions

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)
Discussion started by: pcwiz
4 Replies

5. Shell Programming and Scripting

Permissions script

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)
Discussion started by: user_invalid
7 Replies

6. Shell Programming and Scripting

Script Permissions

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)
Discussion started by: Harleyrci
10 Replies

7. Shell Programming and Scripting

Help on script to change permissions

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)
Discussion started by: fretagi
8 Replies

8. Shell Programming and Scripting

Bash script: "mkdir -p" doesn't work with var(cat x)

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)
Discussion started by: Arnaudh78
1 Replies

9. Shell Programming and Scripting

Use script to mkdir based on file's data

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)
Discussion started by: efsarantis
7 Replies

10. Shell Programming and Scripting

Cd then mkdir from script

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)
Discussion started by: dpawson
10 Replies
mkdir(1)						      General Commands Manual							  mkdir(1)

NAME
mkdir - make a directory SYNOPSIS
mode] dirname ... DESCRIPTION
creates specified directories in mode 0777 (possibly altered by unless specified otherwise by a option (see umask(1)). Standard entries, (for the directory itself) and (for its parent) are created automatically. If dirname already exists, exits with a diagnostic message, and the directory is not changed. Options recognizes the following command-line options: After creating the directory as specified, the file permissions are set to mode, which is a symbolic mode string as defined for (see chmod(1)). The has precedence over Intermediate directories are created as necessary. Otherwise, the full path prefix of dirname must already exist. requires write permission in the parent directory. For each directory name in the pathname prefix of the dirname argument that is not the name of an existing directory, the specified directory is created using the current setting, except that the equivalent of is done on each component to ensure that can create lower directories regardless of the setting of Each directory name in the pathname prefix of the dirname argument that matches an existing directory is ignored without error. If an intermediate path component exists, but has permissions set to prevent writing or searching, fails with an error message. If the option is used, the directory specified by dirname (excluding directories in the pathname prefix) is created with the permissions specified by mode. Only subdirectories can be created (see limits(5)). Access Control Lists - JFS File Systems Only If the parent directory has an access control list (ACL, see aclv(5)), and that ACL contains default entries, an ACL is created for the new directory, and the parent directory's default entries are applied to the new directory's ACL, both as regular entries and as default entries. EXTERNAL INFLUENCES
For information about the UNIX standard environment, see standards(5). Environment Variables provides a default value for the internationalization variables that are unset or null. If is unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables contains an invalid setting, will behave as if all internationalization variables are set to See environ(5). If set to a non-empty string value, overrides the values of all the other internationalization variables. determines the interpretation of text as single and/or multi-byte characters, the classification of characters as printable, and the char- acters matched by character class expressions in regular expressions. determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informa- tive messages written to standard output. determines the location of message catalogues for the processing of International Code Set Support Single- and multi-byte character code sets are supported. DIAGNOSTICS
returns exit code 0 if all directories were created successfully. Otherwise, it prints a diagnostic and returns non-zero. returns exit code 0 if the option was specified, and all the specified directories now exist. If any of the intermediate directories do not have search or write permission (with the option), prints a diagnostic and returns non-zero. EXAMPLES
Create directory beneath existing directory in the current directory: Create directory path underneath the current directory and set permissions on directory to read-only for all users which is equivalent to (see chmod(1)): If directories or and already exist, only the missing directories in the specified path are created. SEE ALSO
rm(1), setacl(1), sh(1), umask(1), aclv(5), standards(5). STANDARDS CONFORMANCE
mkdir(1)
All times are GMT -4. The time now is 11:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy