I'm a newbie to scripting languages trying to learn bash programming.
I have very basic question. Suppose I want to create three folders like $HOME/folder/
with two child folders folder1
and folder2
.
If I execute command in shell like
mkdir -p $HOME/folder/{folder1,folder2}
folder will be created along with child folder.
If the same thing is executed through script I'm not able get expected result. If
sample.sh
contains#!/bin/sh mkdir -p $HOME/folder/{folder1,folder2}
and I execute
sh ./sample.sh
, the first folder will be created then in that a single{folder1,folder2}
directory is created. The separate child folders are not created.
My query is
How the script file works when we compared to as terminal command? i.e., why is it not the same?
How to make it work?