Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Shell – making directories – Shell script has different outcome then Shell

I am trying to make a shell script that makes directories numbered from 01-13.

I use command mkdir -p test/file{01..13}

when I run command via shell script it names directories as 1,2,..,13 but when I use the command in shell itself, it names it correctly as 01,02,..,13. (see image below)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there a way to fix this?

enter image description here

>Solution :

Your interactive shell is zsh, but you run the script with sh. To run your script with zsh, call zsh soubor2.sh.

Alternatively, and recommended, add a shebang line to your script: #!/bin/zsh and mark it executable with chmod u+x soubor2.sh. Then you can execute it with just ./soubor2.sh and it will be executed with the right shell automatically.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading