Create Directories in Linux

the mkdir command creates one or more directories, generating errors if the file name already exists or when attempting to create a directory in a parent directory that doesn’t exists. The –p parent option creates missing parent directories for the requested destination. Be cautious when using mkdir –p, since accidental spelling mistakes create unintended directories without generating error messages.

Linux mkdir

[root@CentOs ~]# mkdir -p /root/Video/Watched

The mkdir failed because Video was misspelled. “Video” does not exist as a location in which to create the Watched sub-directory. If a -p were used. The user would not have received an error message.

Linux mkdir -p

[root@CentOs]# mkdir -p /root/TV/Chapter1 /root/TV/Chapter2

The above mkdir crated two ChapterN sub-directories with one command. The -p parent option created the missing parent directory TV.

For more details see man page




Tech info

Comments