I have a variable in my bash script whose value is something like this:
~/a/b/c
Note that it is unexpanded tilde. When I do ls -lt on this
Here is the POSIX function equivalent of Håkon Hægland's Bash answer
expand_tilde() { tilde_less="${1#\~/}" [ "$1" != "$tilde_less" ] && tilde_less="$HOME/$tilde_less" printf '%s' "$tilde_less" }
2017-12-10 edit: add '%s' per @CharlesDuffy in the comments.
'%s'