0

I need to create directory structure using mkdir for directory creation and touch for creating files using only relative paths.

1

3
  • i have attached the image.For that i have create directory structure
    – Nagashree
    Jun 24, 2020 at 19:49
  • Is this some kind of homework? We can help you, but it is not a good idea that we do the homework for you. Please try, and show the commands that you have tried. (Edit your original question. Indent each line with code with 4 spaces to render it as code.)
    – sudodus
    Jun 24, 2020 at 19:52
  • 1
    You can use -p switch for mkdir to create path of folders. mkdir -p mydir/colors/basic. Still You will have to do this few times to create entire structure. Jun 24, 2020 at 20:28

1 Answer 1

3

Using bash brace expansion to create the directory structure:

$ mkdir -p mydir/{colors/{basic,blanded},shape,animals/{mammals,reptiles}} && \
touch mydir/{colors/{basic/{red,blue,green},blanded/{yellow,orange,pink}},shape/{circle,square,cube},animals/{mammals/{platypus,bat,dog},reptiles/{snakes,crocodile,lizard}}}

You can examine the directory structure with the tree command.

Not the answer you're looking for? Browse other questions tagged .