0

Let's say I have the following variable set:

directoryTrash="~/trash"

How can I use this variable to create the directory it describes? I've tried using it with mkdir in the following way:

mkdir -p "${directoryTrash}"

When I do this, the directory "~" is created in the working directory and the subdirectory "trash" is created within it. How can I use tilde expansion to get the full path so that mkdir can do what I want it to do?

d3pd
  • 6,679
  • 18
  • 56
  • 111
  • [Probable duplicate](http://stackoverflow.com/questions/3963716/how-to-manually-expand-a-special-variable-ex-tilde-in-bash). Use `eval`. Or if that's offensive, `$HOME` is a reasonable, though not always complete, substitute. – bishop Nov 05 '14 at 16:11
  • If `$HOME` contains your home directory: `mkdir -p ${directoryTrash/#\~/$HOME}` – Cyrus Nov 05 '14 at 20:18

0 Answers0