Вопрос

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?

Это было полезно?

Решение 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

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top