I'm not a Unix guru.

I'm running OS X 10.8.3 Mountain Lion. Today I removed Macports from my machine. I believe macports left some cruft in my `~/.bash_profile which I would like to remove (the cruft—not the entire file contents). Currently, my $PATH looks like this:

echo $PATH /opt/local/bin:/opt/local/sbin:/usr/local/opt/ruby/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

I see some redundancy i.e. /opt/local/bin: appears 3 times. In my home directory I see several files relating to .bash_profile:

ls .bash*

Can I remove the two .bash_profile.macports… files? How can I remove the extra items listed in my $PATH?


The .bash_profile.macports-saved... are not actually executed, they're just backups. You can remove them if you don't need them.

.bash_history contains the last commands you executed on the shell. There's no point in deleting it, but you can remove it if you want.

If you uninstalled MacPorts (and deleted /opt), you can remove from your PATH all the subdirectories of /opt.

Just look in .profile, .bash_profile and .bashrc for any modification of your PATH.

For example, in my .profile MacPorts added:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

You can remove lines like this, or just single directories.

  • Thank you. To remove items from my PATH, is that done by writing a new export command like the one you have shown which exclude the items I want to remove?
    – user49516
    May 16 '13 at 21:33
  • You can reset the PATH, of course, but the best idea is to remove the directories from the commands which added them. You should find those commands in the files listed above, into your home folder. Try editing .profile in a text editor, the settings should be there. Also see this question.
    – pietrodn
    May 16 '13 at 21:43
  • @pietrodn - the edit should be for .bash_profile and .bashrc not .profile - look at the INVOCATION section of man bash to see all the files it uses
    – mmmmmm
    May 16 '13 at 23:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .