Why does the following command: mkdir -p '~/something'
creates a directory directory named as '~' in the current, instead of creating a directory named as something
in the home directory? Is there any way to fix this?
ps. I get the value ~/something
as an environment variable wrapped in single quotation.
~
is not expanded when quoted: therefore the system is not able to translate it as "my home folder". If you want to use the quotes (for instance, because there are whitespaces in the folder path), better use double quotes replacing the tilde sign with the variable$HOME
. Summarizing:mkdir -p "$HOME/something"
– Lorenz Keel May 25 '21 at 13:39