How do I change $PATH to default on a mac?

Viewed 2537

I am a newbie to UNIX programming and I wanted to install Sqlpackage. So I followed the instructions on the Microsoft site: 1) Download sqlpackage for macOS. 2)To extract the file and launch sqlpackage, open a new Terminal window and type the following commands:

`$mkdir sqlpackage
$ unzip ~/Downloads/sqlpackage-osx-<version string>.zip ~/sqlpackage 
$ echo 'export PATH="$PATH:~/sqlpackage"' >> ~/.bash_profile
$ source ~/.bash_profile
$ sqlpackage` 

I only skipped the second line, because it came already unzipped after the download, so I simply placed it into the new directory. But nothing happened, I couldn't launch sqlpackage from the terminal, I got 'command not found'. So I tried it aging. I have no idea how did I get there but now when I open a new terminal and enter $PATH this is what I get '

 Air-Anna:~ anna$ $PATH
    -bash: ~/sqlpackage:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin: No such file or directory

'

I opened the /.bash_profile with vim via the terminal and this is what it looks like

export PATH="$PATH:~/sqlpackage"
export PATH="$PATH:~/sqlpackage"
export PATH="$PATH:~/sqlpackage-osx-x64"
export PATH="$PATH:~/sqlpackage"
export PATH="~/sqlpackage" 
export PATH="$PATH:~/sqlpackage"
export PATH="~/sqlpackage"
export PATH="$PATH:~/sqlpackage"
export PATH="~/sqlpackage"
export PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"~/.bash_profile" 10L, 361C

' Seems like a mess what should I do?

1 Answers

Rename your ~/.bash_profile file by running the following in Terminal:

rm ~/.bash_profile

and restart the Terminal. This should restore the system default path for you. To view the current value of PATH variable, type:

echo $PATH

in the Terminal. Do not simply type $PATH at the prompt as it would expand the value of the PATH variable and try to run it as a command.

To make the sqlpackage command available in your command PATH, add the sqlpackage files as instructed under a directory named sqlpackage in your Home directory, and then run the following on the Terminal:

export PATH="$PATH:~/sqlpackage"' >> ~/.bash_profile

followed by:

source ~/.bash_profile

This should set you up.

Related