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
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
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
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
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
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
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
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
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
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
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) Linux Programmer's Manual MKDIR(2)
NAME
mkdir - create a directory
SYNOPSIS
#include <sys/stat.h>
#include <sys/types.h>
int mkdir(const char *pathname, mode_t mode);
DESCRIPTION
mkdir() attempts to create a directory named pathname.
The argument mode specifies the permissions to use. It is modified by the process's umask in the usual way: the permissions of the created
directory are (mode & ~umask & 0777). Other mode bits of the created directory depend on the operating system. For Linux, see below.
The newly created directory will be owned by the effective user ID of the process. If the directory containing the file has the set-group-
ID bit set, or if the file system is mounted with BSD group semantics (mount -o bsdgroups or, synonymously mount -o grpid), the new direc-
tory will inherit the group ownership from its parent; otherwise it will be owned by the effective group ID of the process.
If the parent directory has the set-group-ID bit set then so will the newly created directory.
RETURN VALUE
mkdir() returns zero on success, or -1 if an error occurred (in which case, errno is set appropriately).
ERRORS
EACCES The parent directory does not allow write permission to the process, or one of the directories in pathname did not allow search per-
mission. (See also path_resolution(7).)
EDQUOT The user's quota of disk blocks or inodes on the file system has been exhausted.
EEXIST pathname already exists (not necessarily as a directory). This includes the case where pathname is a symbolic link, dangling or
not.
EFAULT pathname points outside your accessible address space.
ELOOP Too many symbolic links were encountered in resolving pathname.
EMLINK The number of links to the parent directory would exceed LINK_MAX.
ENAMETOOLONG
pathname was too long.
ENOENT A directory component in pathname does not exist or is a dangling symbolic link.
ENOMEM Insufficient kernel memory was available.
ENOSPC The device containing pathname has no room for the new directory.
ENOSPC The new directory cannot be created because the user's disk quota is exhausted.
ENOTDIR
A component used as a directory in pathname is not, in fact, a directory.
EPERM The file system containing pathname does not support the creation of directories.
EROFS pathname refers to a file on a read-only file system.
CONFORMING TO
SVr4, BSD, POSIX.1-2001.
NOTES
Under Linux apart from the permission bits, only the S_ISVTX mode bit is honored. That is, under Linux the created directory actually gets
mode (mode & ~umask & 01777). See also stat(2).
There are many infelicities in the protocol underlying NFS. Some of these affect mkdir().
SEE ALSO
mkdir(1), chmod(2), chown(2), mkdirat(2), mknod(2), mount(2), rmdir(2), stat(2), umask(2), unlink(2), path_resolution(7)
COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2013-01-27 MKDIR(2)