26
11

More than 1 year has passed since last update.

Linux — 既に存在するディレクトリを mkdir しようとしたときのエラーを無視する ( $ mkdir -p )

Last updated at Posted at 2016-06-27
mkdir -p some_dir

と書けば、何度やっても怒られない。

実際にはエラーを無視するのではなく「既にディレクトリが存在する場合は何もしない」という動作らしい。

Help

$ man mkdir | cat

MKDIR(1)                  BSD General Commands Manual                 MKDIR(1)

NAME
     mkdir -- make directories

SYNOPSIS
     mkdir [-pv] [-m mode] directory_name ...

...

     -p      Create intermediate directories as required.  If this option is
             not specified, the full path prefix of each operand must already
             exist.  On the other hand, with this option specified, no error
             will be reported if a directory given as an operand already
             exists.  Intermediate directories are created with permission
             bits of rwxrwxrwx (0777) as modified by the current umask, plus
             write and search permission for the owner.

参考

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

26
11
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
11