Skip to main content
2 of 2
added 144 characters in body
m0dular
  • 1.3k
  • 7
  • 8

One possible answer:

eval echo "$x"

Since you're reading input from a file, I would not do this.

You could search and replace the ~ with the value of $HOME, like this:

x='~/.config'
x=${x/#\~/${HOME}}
echo "$x"

Gives me:

/home/adrian/.config

EDIT: changed the search and replace to ${x/#\~/${HOME}} in order to only replace the initial ~. Thanks @user137369 for the suggestion.

m0dular
  • 1.3k
  • 7
  • 8