I want to create a directory given in a variable value. First let's ensure the directory can be created via the simplest command:
$ mkdir ~/opt
[ec2-user@ip-172-31-15-193 ~]$ ls ~/opt
[ec2-user@ip-172-31-15-193 ~]$ ls -l ~/opt
total 0
What is the syntax for using a variable in place of the hard-coded path? Here is what has been tried:
$ BDIR="~/opt"
$ mkdir $BDIR
mkdir: cannot create directory ‘~/opt’: No such file or directory
Also:
$ mkdir "$BDIR"
mkdir: cannot create directory ‘~/opt’: No such file or directory