0

I have a couple of scripts for configuring new computers. I have a section dedicated to osx, where I create specific osx stuff. I wanted to change the default location for screenshots,but first I need to create the required folder. However, when I try to create the folder at ~/Documents/screenshots I get a variety of errors:

  • If I just use mkdir, then it tells me that the file already exists
  • If I add the -p option then I get no error, but nothing happens, the file does not get created

I tried the same code on the console directly with identical results. Here is a small part of the code. The get boolean response is just a small function that returs true or false depending if the user types Yes or No

#!/bin/bash

  screenshotsFolder="~/Documents/screenshots"
  if get_boolean_response "Create a folder for the screenshots at $screenshotsFolder?"; then
     mkdir "$screenshotsFolder"
  fi

I tried changing the name to a random one, but I get exactly the same results. Any advice?

Danielo515
  • 5,996
  • 4
  • 32
  • 66
  • Yes, you're right, it's the same problem. However, I was not able to find that answer with my current mindset, that's why I opened an issue with a different wording that will match less technical searches. Should I close/delete it or making the solution easier to find deserves the duplication ? – Danielo515 Jan 12 '19 at 13:30
  • use `$HOME` instead of `~`: `screenshotsFolder="$HOME/Documents/screenshots"` – Yoric Jan 12 '19 at 13:32

0 Answers0