Why the following script does not work:
#!/bin/bash mkdir -p ~/test1 MY_DYR='~/test1' if [ -d $MY_DYR ]; then echo 'TRUE' fi echo 'Done!' Expected to see TRUE ...
Because it is part of the rules of the ~ expression: the expression ~ does not work if it is enclosed in quotes.
Do not enclose the path with ~ in quotes.
file=~/path/to/file If you still need to screen part of the path, then do this:
file=~/"path with spaces/to/file" Use $HOME instead of ~ .
file="$HOME/path/to/file" Source: https://ru.stackoverflow.com/questions/587461/
All Articles