I tried a one line script that worked in one Linux based distro(Linux mint) but doesn’t work in another(Fedora). I typed the following line in my bash script.
mkdir $HOME/folder123
The error i receive:
bash: create.sh: No such file or directory
I tried creating a folder myself, it gave me a permission denied?
To clear things hopefully: mkdir is in the script create.sh and i run it in the terminal with the command bash create.sh
If I interpret your post correctly, you have a file
create.shthat containsmkdir $HOME/folder123, and you’re trying to run it by typingcreate.sh.To execute a script,
chmod +x yourscript.shthen run it with either./yourscript.shif it’s in the current directory, or/home/whatever/yourdir/yourscript.shif it’s in another directory.To make just
yourscript.shwork, you have to place it in a directory listen in $PATH.You can do this by copying it to any of the directories listed in
echo $PATH.Alternatively, you can create a new directory such as
mkdir /home/you/binand then addexport PATH="$PATH:/home/you/bin"at the end of your~/.bashrc. Also make sure~/.bash_profilecontains the linesource .bashrc. Then log out and in again.