Why does mkdir not work?  [Solved]

Help for Current Versions of MX
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
madmax25
Posts: 321
Joined: Fri Apr 10, 2020 12:40 pm

Why does mkdir not work?

#1 Post by madmax25 »

I'm inside a folder New folder and I'm trying to create folders 401 to 450, using this command

Code: Select all

mkdir ./{401..450}
which is inside of a file called create_folders.sh.

If I try to "Execute in terminal", using the context menu, I get an error message telling me:

Code: Select all

Executing child process failed
Child process "path/currently/opened" not executed
file or folder not found
...even that I'm already in that folder.

What's the fault here, please?

Charlie Brown

Re: Why does mkdir not work?

#2 Post by Charlie Brown »

Then, does it work if you issue it directly in a terminal?

Also: Is the sh executable? ( chmod +x create_folders.sh )

User avatar
Adrian
Developer
Posts: 8875
Joined: Wed Jul 12, 2006 1:42 am

Re: Why does mkdir not work?

#3 Post by Adrian »

Anything else is that script? I tried the command and it works fine for me, I would change two things, I would not use spaces in "New Folder" I would use "New_Folder" or something like that and probably won't use ./ in the mkdir command, that's not necessary since it run that in current folder, I would use "mkdir {401..450}"

Please post the script...

Charlie Brown

Re: Why does mkdir not work?

#4 Post by Charlie Brown »

Adrian wrote: Wed Jan 17, 2024 8:25 am... tried the command and it works fine for me ...
Same here. However it works here also in a folder with spaces: Charlie Brown :) (... either with and without ./ )

madmax25
Posts: 321
Joined: Fri Apr 10, 2020 12:40 pm

Re: Why does mkdir not work?

#5 Post by madmax25 »

Sorry, of course, I mean New_folder with the underline.

It is actually not an entire script. It is just the command

Code: Select all

mkdir {401..450}
in a .sh file (nothing else inside), which is indeed executable already.

I tried both

Code: Select all

mkdir {401..450}
and

Code: Select all

mkdir ./{401..450}
but none of them worked.

But that command (both of them) did work perfectly, when executed directly from within a terminal.
So, I don't understand why it doesn't work if it is inside of a .sh file?

I checked the properties of that file and noticed, the owner is root.
That file is on a NTFS partition btw..
Could this be the reason?

User avatar
timkb4cq
Developer
Posts: 3561
Joined: Wed Jul 12, 2006 4:05 pm

Re: Why does mkdir not work?

#6 Post by timkb4cq »

It's because that syntax is only valid in bash/dash. You are in bash at the command line so it works. A shell script is not unless specified.
if you add the shebang line

Code: Select all

#!/bin/bash
to the first line of the script file it works.
HP Pavillion TP01, AMD Ryzen 3 5300G (quad core), Crucial 500GB SSD, Toshiba 6TB 7200rpm
Dell Inspiron 15, AMD Ryzen 7 2700u (quad core). Sabrent 500GB nvme, Seagate 1TB

User avatar
CharlesV
Global Moderator
Posts: 7081
Joined: Sun Jul 07, 2019 5:11 pm

Re: Why does mkdir not work?

#7 Post by CharlesV »

This worked perfectly for me on an ntfs drive.

You might try formatting your script as follows: (although mine worked fine with out this.)

Code: Select all

#!/bin/bash
 
mkdir ./{401..450}

*QSI = Quick System Info from menu (Copy for Forum)
*MXPI = MX Package Installer
*Please check the solved checkbox on the post that solved it.
*Linux -This is the way!

madmax25
Posts: 321
Joined: Fri Apr 10, 2020 12:40 pm

Re: Why does mkdir not work?

#8 Post by madmax25 »

After adding the shebang, it still failed to work, with same error message as in the opening post.

@ CharlesV
I copied your code exactly as it is, but still the same negative result.
Last edited by madmax25 on Wed Jan 17, 2024 1:29 pm, edited 1 time in total.

User avatar
korilius
Posts: 78
Joined: Sat Oct 15, 2022 9:31 pm

Re: Why does mkdir not work?

#9 Post by korilius »

Post the script somewhere so we can look at it that way. It probably doesn't matter, but.. post which MX version you're running as well.
Guide - How to ask for help

Please @korilius when replying to me
Desktop: MX-21.2.1_x64 “ahs”, KDE | ASUS mb | Ryzen 5 5500 cpu | Radeon 6500 XT gpu | 16gb mem | Crucial 1Tb ssd

madmax25
Posts: 321
Joined: Fri Apr 10, 2020 12:40 pm

Re: Why does mkdir not work?

#10 Post by madmax25 »

On my latest attempt I was using the code from CharlesV.

I'm still running MX 19.4 xfce 64 bit.

Actually, I planned to upgrade to the latest MX on both my PC and notebook right after the new year began, but then my notebook died and I'm currently waiting for the new one to be delivered (it is already ordered).

Post Reply

Return to “MX Help”