command line - compare my current directory to a predefined directory in unix -


I am trying to write a small script which will install the extension for use at present. However, If I do ssh in the box, I do not always want to see if I am in the right directory to install my extension. Instead, I will just run a command and in that command it checks the current working directory and then I predefine one of the comparison of that directory's end. For example, I install my extension, you have guessed it, extensions folder. Say I run pwd and it excludes /home/site.com/not_extensions_directory/ . Then the script will see that the current directory is not extensions , then I can kill the install and print a warning.

The script will know with a better solution that I am not in the correct directory and then point to the user

you "(yes / no) ?

What would be the correct syntax for doing this on a Unix box (either solution)?

Put it at the top of your script, replace / path / to / extensions with your extension folder.

  CURRENT_DIR = "$ (cd" $ (dirname "$ 0") "& amp; PVD) "If [$ CURRENT_DIR! = / Path / from / extension]; then echo" need to run this script with / path / to / extensions "exit 1fi    

Comments