Updating the path in OSX Unix

curiouswebster
curiouswebster used Ask the Experts™
on
I need to Add the ADK to my PATH and here are the instructions:

"The Android tools are needed in your path. In your home directory, edit your .profile or .bash_profile with your favorite text editor and insert the following lines."

But I can not find a .profile file to edit.

What can I do??

Thanks.

Also, what is the name of the UNIX inside OSX
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Launch 'Terminal'.
Enter

echo 'export PATH=xyz:$PATH' >> ~/.bash_profile

(and press the <return> key) ... where 'xyz' is your desired path(s).

03. Open another 'Terminal' window.
04. Enter ...

env

<return> ... and note that 'PATH' now includes 'xyz'.

curiouswebsterSoftware Engineer

Author

Commented:
Before I typed your command, I entered "env" and happily saw a list of path entries. But after I entered your command "env" resulted in:

-bash: env: command not found

Could I have wiped out the file? By chance I just bought a hard disk and had just got my first full backup completed before making this change. But that's a last resort.

Could I have damaged the file?

curiouswebsterSoftware Engineer

Author

Commented:
Is there a way to see the filename in Finder?
To see all files in finder:
In the terminal type:

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder

You did open a new terminal session when typing env, correct?
curiouswebsterSoftware Engineer

Author

Commented:
Yes, I did close terminal before typing enfv again, except I now see it shows up when I press Command Tab, but when I choose it in the tab order, no window appears.

And I get the same response:

-bash: env: command not found


when I type either of these:

defaults write com.apple.finder AppleShowAllFiles TRUE
<Enter>
killall Finder
 
or

defaults write com.apple.finder AppleShowAllFiles TRUE killall Finder
Open terminal and please type

echo $PATH

Answer back with the result.
curiouswebsterSoftware Engineer

Author

Commented:
/opt/android-sdk/tools:PATH

this is the path I just added. But I thought the long list had others also in the path? I typed env and it produced about 20 lines.
Can you copy and paste the lines of your original env please.
curiouswebsterSoftware Engineer

Author

Commented:
they are long gone. I  closed the window.
curiouswebsterSoftware Engineer

Author

Commented:
Is there a way to get it from TimeMachine? I finished a full backup minutes before trying to update the path.
Try this first

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/android-sdk/tools

Send back the result of echo $PATH

Commented:
If you want your PATH to be setup for all apps, including those that you don't launch from the terminal, you need to edit this file:

~/.MacOSX/environment.plist

You can do this in the Finder by doing

Command-Shift-G

Type ~/.MacOSX into the box and click Go

Dbl-click the environment.plist file

This should open something you can use to edit the property list

Change the entry for PATH to be the thing you want (i.e., add the Android value at the end separated by a : colon)

Logout and login again.

Commented:
Oh, and on any unix you can type

uname -a

in any shell prompt and get info about the unix version.  On my mac, I get

Darwin <name of machine> 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
curiouswebsterSoftware Engineer

Author

Commented:
> export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/android-sdk/tools

Are those colons?
Commented:
yes
curiouswebsterSoftware Engineer

Author

Commented:
and did my file get corrupted? I have a reservation at the Genius Bar this afternoon and will have a Mac expert take a look, and possibly help me to restore that file.
curiouswebsterSoftware Engineer

Author

Commented:
That's not to say you are not a Mac expert :) It sounds like you are.
Commented:
What file? And what makes you think it got corrupted?
Commented:
oh, the other guy told you to put some stuff into .bash_profile

Did you perhaps not use >> (two greater thans) and instead use only on >

Then you overwrote the contents of the file, rather that appending to it.

I'd try to restore that file from TimeMachine.
Sr. AIX Admin
Commented:
NEWBIEWEB...

The problem is, you didn't type the $  that ifreda suggested in the first place.

$PATH contains your current path.  What ifreda was showing you was to put your xyz path just ahead of everything you already had defined.

You have not corrupted anything, just gotten yourself into a bit of a bind at the moment.  As the PATH is being overridden by your typo.

This is easily resolved, but somewhat tedious to do over a message thread.
You'll have to fully qualify your commands, as the search path is dorked up at the moment.

Here's my suggestion at fixing it.  you need to put a $ before the PATH in your bash_profile
Let's make a backup of the file... then use sed (stream editior), to change the :PATH to :$PATH as ifreda suggested in the first place
Please type these commands carefully.. every ~ $ : / \ etc are all important

/usr/bin/cp  ~/.bash_profile   ~/.bash_profile-backup
/usr/bin/sed -e 's/:PATH/:\$PATH/'  ~/.bash_profile  >   ~/.bash_profile-new
/usr/bin/mv  ~/.bash_profile-new    ~/.bash_profile

NOW... open another terminal window, and type   echo $PATH
and post the response..
curiouswebsterSoftware Engineer

Author

Commented:
I will report back after my afternoon appointment with a Genius.

Thanks for all the help!
curiouswebsterSoftware Engineer

Author

Commented:
I just visited the Apple store and was advised to restore my disk from the original CD's that came with the machine. I thought that was extreme, but thinking back to my days woring with UNIX: you can restore a file, but if a single attribute is wrong on such an important file, it could be the end of my system. So I plan to run the restore...

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial