0

I am inside a bash script located at /home/[username]/Documents/work/script.sh. I want to create two folders, potato/tomato at /home/[username]/. To do so, here's my script:

mkdir -p "~/potato/tomato"

However, this creates the two folders like this: /home/[username]/Documents/work/potato/tomato.

I don't want to create these folders in my current working directory, I want them in my current user's home directory. What am I doing wrong and what should I change?

ThomasFromUganda
  • 380
  • 3
  • 17

1 Answers1

0

Remove the quotes:

mkdir -p ~/potato/tomato

By using quotes, it's evaluating the home directory and using your username as a name in the path, starting from the current working directly. Without the quotes, it will evaluate correctly to the absolutely path of your home directory.

djsumdog
  • 2,560
  • 1
  • 29
  • 55