How to create nested directories?

You can create nested directories in Linux using the mkdir command with the -p option. This allows you to create a directory structure where parent directories are created automatically if they do not already exist.

Syntax:

mkdir -p parent_directory/child_directory/grandchild_directory

Example:

To create a nested directory structure like projects/web_app/src/components, you would use:

mkdir -p projects/web_app/src/components

Explanation:

  • The -p option ensures that all parent directories (projects, web_app, src) are created if they do not exist.
  • This command will create the entire path in one go without raising an error if any part of the path already exists.

If you have any further questions or need more examples, feel free to ask!

0 Comments

no data
Be the first to share your comment!