Im trying to check if a series of directory exists and if not create them, and am having issues. All the instances of test return with the error &quot;test: [-d: unary operator expected&quot; . Searching around I see that if the variable is in double quotes its solves the problem - but for some reason, not for me. The script still makes the directories if the don&#39;t exists, however if they DO - it still tries to create them.<br>
<br>What noob things am I doing wrong here?<br><br>This is just one small but of my puzzle - if there is anybody knowledgeable in shell scripting that could give me a few hours to in the next day or so - I&#39;d be happy to pay for your time. <br>
<br>Cheers,<br>Ben Rush<br><br>[code]<br>#!/bin/bash<br>location_Parent=~/Documents/sight_of_sound<br>location_IMG=~/Documents/Sight_of_sound/IMG<br>location_AUD=~/Documents/Sight_of_sound/AUD<br><br>if test [-d &quot;$location_Parent&quot;]<br>
then<br>echo &quot;Parent Directory OK&quot;<br>else<br>    echo &quot;Error: Parent directory does not exist. Creating directory&quot;<br>    mkdir $location_Parent<br>fi<br><br>if test [-d &quot;$location_IMG&quot;]<br>
 then<br>    echo &quot;IMG Directory OK&quot;<br>else<br>    echo &quot;Error: IMG directory does not exist. Creating directory&quot;<br>    mkdir $location_IMG<br>fi<br><br>if test [-d &quot;$location_AUD&quot;]<br>then<br>
    echo &quot;AUD Directory OK&quot;<br>else<br>    echo &quot;Error: AUD directory does not exist. Creating directory&quot;<br>    mkdir $location_AUD<br>fi<br>[/code]<br><br><br><br>