We know that
$HOME refer to the home directory of the current user. (For me
But I can't use it in bash scripting. Here is a simple example script:
#!/bin/bash echo -n "Enter Directory Path:" read dir1 cd $dir1
But When executed, it gives error
No such file or directory as follows:
$ ./script Enter Directory Path:~/Desktop ./script: line 4: cd: ~/Desktop: No such file or directory
/home/pandya used instead of
~ ,then it is working.
Same problem with
Thus, How to properly use
$HOME in such bash scripting?