I have environment variable export MY_WORK_DIR="~/project"
.
While I'm using below command, it give me an error:
realpath $MY_WORK_DIR
realpath: '~/project': No such file or directory
In my guess, the ~
is not processed while using this env variable.
BTW, export MY_WORK_DIR=~/project
is not an option for me. ~
should be in the string.
Could you please guide me how to get real path from envrionment variable ~/project
?
EDIT
Sorry. The variable is from other app so I cannot modify the environment variable which contains tilde. (Storing variable with tilde expanded form is not an option).
EDIT2
Is it safe to use eval
command like this? eval "echo ${MY_WORK_DIR}"
. It works for my use.