Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to create folder by using if and elif condition? Post 302966401 by Don Cragun on Thursday 11th of February 2016 03:10:44 PM
Old 02-11-2016
Quote:
Originally Posted by RudiC
The -p option to mkdir will make it "not fail" on existing directories, so sth serious must happen to select the failure branch.
Serious, yes. Unusual, no. Unlikely, maybe not. If the directory in which a new directory is to be created is not writeable by the user running the script, mkdir -p will fail with an EPERM error. If a non-directory (or symbolic link pointing to a non-directory) file exists with the name of a directory to be created, mkdir -p will fail with an EEXIST error. And, of course, EACCES, ELOOP, EMLINK, ENAMETOOLONG, ENOSPC, ENOTDIR, and EROFS errors are also possible.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

if...elif...fi condition in Unix

Hey guyes! i have a little problem in if condition, can anybody please solve my problem? Here what i am doing. if then echo "int1 is equal to int2" elif then echo "int1 is greater than int2" else echo "int1 is smaller than int2" fiNo, matter int1 is smaller than... (9 Replies)
Discussion started by: abidmalik
9 Replies

2. AIX

AIX - create folder in hdisk1 instead

Dear All, I have two h.disks. Please advice for how to create a new folder/directory in hdisk1 instead of the hdisk0? I need to use the folder to store for xmlfiles for my application accessing to read it. Thank a lots. Best Regards, Tom (3 Replies)
Discussion started by: lwy2020
3 Replies

3. Shell Programming and Scripting

how to create folder wen the condition satisfied

hi i hav files ha1j ha2m ha3n ha4q ha5s ...like tat im having some 20 files ..and i want to create a folder as the same amount of files which im having wen the condition if loop is satisfied .. thank you (5 Replies)
Discussion started by: maximas
5 Replies

4. Shell Programming and Scripting

how to create folder and sub-folder in UNIX ?

Hi all, I have the following code to check the whether the folder is exist in my system. if ; then echo 'folder exist'; else echo 'folder not exist'; mkdir /home/batch/testing ; fi When I remove the "testing" folder from "/home/batch" directory, the code is working fine. But when I... (2 Replies)
Discussion started by: suigion
2 Replies

5. Shell Programming and Scripting

create separate file after checking condition..

Problem : I want to create a separate file for country list if condition is true. Please help. ***************************************************** Input file: SV-INCR-139302-365540488-201104090934.sqllog SV-INCR-1082-552793184-201104040805.sqllog SV-INCR-1077-855045741-201104040805.sqllog... (4 Replies)
Discussion started by: humaemo
4 Replies

6. UNIX for Dummies Questions & Answers

Create a condition for a non-included string

hey, just want to ask how to check this scenario a="apple banana cherry" if egg=0 fi how do you do the condition? thanks! (2 Replies)
Discussion started by: h0ujun
2 Replies

7. UNIX for Dummies Questions & Answers

Create a file on UNIX with multiple columns on certain condition

I need to write the list of files to a new file in one column , the second column would contain the first line of that file (header record extracted through head -1 ) and the third column would contain the last record of that file (trailer record tail -1 ) . Example :- folder where the files... (8 Replies)
Discussion started by: IshuGupta
8 Replies

8. Shell Programming and Scripting

Create Dynamic if condition

Create Dynamic If condition Hi, I have a file color.txt which has data as shown below Red Blue Green Yellow White Pink Black Based on a variable I execute a tail command as shown below tail -${LEFT_OVR} color.txt LEFT_OVR can be any number less than count of number of lines in a... (7 Replies)
Discussion started by: wahi80
7 Replies

9. Shell Programming and Scripting

Create a shared folder using acl

Hello. I need some help to create a shared folder. A group 'publicuser' has been created. A user 'publicuser' has been created ( no login, no home) and belongs to group 'publicuser'. A public folder '/doc' has been created and owner is publicuser:publicuser. All users belonging to group... (12 Replies)
Discussion started by: jcdole
12 Replies

10. Shell Programming and Scripting

Issue with condition "if then elif else fi"

Hi everybody, I must get trought a shell script 3 arguments. 1st argument = $1 (can take values REP1..4) 2nd argument = $2 (can take values A..Z) 3rd arguement = $3 (also can take values A...Z) I've written this code : #!/bin/bash if then liste=/data/folder1 echo... (6 Replies)
Discussion started by: shellX
6 Replies
mkdir(2)							   System Calls 							  mkdir(2)

NAME
mkdir - make a directory SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int mkdir(const char *path, mode_t mode); DESCRIPTION
The mkdir() function creates a new directory named by the path name pointed to by path. The mode of the new directory is initialized from mode (see chmod(2) for values of mode). The protection part of the mode argument is modified by the process's file creation mask (see umask(2)). The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to the process's effective group ID, or if the S_ISGID bit is set in the parent directory, then the group ID of the directory is inherited from the parent. The S_ISGID bit of the new directory is inherited from the parent directory. If path names a symbolic link, mkdir() fails and sets errno to EEXIST. The newly created directory is empty with the exception of entries for itself (.) and its parent directory (..). Upon successful completion, mkdir() marks for update the st_atime, st_ctime and st_mtime fields of the directory. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned, no directory is created, and errno is set to indicate the error. ERRORS
The mkdir() function will fail if: EACCES Either a component of the path prefix denies search permission or write permission is denied on the parent directory of the directory to be created. EDQUOT The directory where the new file entry is being placed cannot be extended because the user's quota of disk blocks on that file system has been exhausted; the new directory cannot be created because the user's quota of disk blocks on that file system has been exhausted; or the user's quota of inodes on the file system where the file is being created has been exhausted. EEXIST The named file already exists. EFAULT The path argument points to an illegal address. EINVAL An attempt was made to create an extended attribute that is a directory. EIO An I/O error has occurred while accessing the file system. ELOOP Too many symbolic links were encountered in translating path. ELOOP A loop exists in symbolic links encountered during resolution of the path argument. EMLINK The maximum number of links to the parent directory would be exceeded. ENAMETOOLONG The length of the path argument exceeds PATH_MAX, or the length of a path component exceeds NAME_MAX while _POSIX_NO_TRUNC is in effect. ENOENT A component of the path prefix does not exist or is a null pathname. ENOLINK The path argument points to a remote machine and the link to that machine is no longer active. ENOSPC No free space is available on the device containing the directory. ENOTDIR A component of the path prefix is not a directory. EROFS The path prefix resides on a read-only file system. The mkdir() function may fail if: ENAMETOOLONG As a result of encountering a symbolic link in resolution of the path argument, the length of the substituted pathname string exceeded {PATH_MAX}. EXAMPLES
Example 1: Create a directory. The following example demonstrates how to create a directory named /home/cnd/mod1, with read, write, and search permissions for owner and group, and with read and search permissions for others. #include <sys/types.h> #include <sys/stat.h> int status; ... status = mkdir("/home/cnd/mod1", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
chmod(2), mknod(2), umask(2), mkdirp(3GEN), stat.h(3HEAD), attributes(5), standards(5) SunOS 5.10 29 Jul 2004 mkdir(2)
All times are GMT -4. The time now is 10:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy