Skip to content

Consider taking a moment to explain mkdir -p #1485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmolesUC opened this issue Apr 11, 2025 · 1 comment
Open

Consider taking a moment to explain mkdir -p #1485

dmolesUC opened this issue Apr 11, 2025 · 1 comment

Comments

@dmolesUC
Copy link

How could the content be improved?

We say

Note that mkdir is not limited to creating single directories one at a time. The -p option allows mkdir to create a directory with nested subdirectories in a single operation:

$ mkdir -p ../project/data ../project/results

but:

  1. we haven't actually used the word "nested" up to this point
  2. as a student, it wouldn't occur to me that just mkdir ../project/data wouldn't work
  3. from the example, it's hard to tell:
    1. that we're creating nested structures (the ../ makes it less obvious)
    2. that -p isn't necessary just to create two directories with one command

It might be clearer if we did something like:

mkdir project1 project2      # shows creating two directories
mkdir project1/data/final    # doesn't work
mkdir -p project1/data/final # shows how -p works
mkdir -p project3/data/final # shows that -p creates multiple levels

Which part of the content does your suggestion apply to?

https://swcarpentry.github.io/shell-novice/instructor/03-create.html#creating-directories

@bkmgit
Copy link
Contributor

bkmgit commented Apr 13, 2025

Thanks for the suggestion. Third line seems like it should be changed:

mkdir project1 project2      # shows creating two directories
mkdir project1/data/final    # doesn't work
mkdir -p project1/data       # shows how -p works
mkdir -p project3/data/final # shows that -p creates multiple levels

This would lengthen the lesson though. There are some exercises at the end, in particular in https://swcarpentry.github.io/shell-novice/instructor/03-create.html#operations-with-multiple-files-and-directories there is a section Reproduce a folder structure maybe it would be better to modify this exercise to clarify the operations? The exercise could be moved so it is next to the section. That way if more discussion is needed, there is space for it, but if time is very short, it can be skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants