Question

Given this script

# cat foo.sh
echo $HOME
set -x
mkdir ~

I am getting this result

# ./foo.sh
/home/Steven Penny
++ mkdir ''
mkdir: cannot create directory `': No such file or directory

If I run mkdir "$HOME" I have no problem. I think the issue is the space in the path, but can someone shed some light on this?

Was it helpful?

Solution 2

The problem was that the /etc/passwd file was missing.

To elaborate, even one this simple will work

Steven Penny::0:0::/home/Steven Penny

OTHER TIPS

Looking at your debug output

++ mkdir ''

looks like "~" in mkdir ~ is expanding to nothing, thus causing mkdir to fail. As mkdir $HOME works fine it means you have enough space in the disk.

Can you check if echo ~ is displaying your home directory.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top