Cleaning up my .bash_profile: Can I delete some of this? 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*
.bash_history
.bash_profile.macports-saved_2012-08-10_at_10:09:18
.bash_profile
.bashrc
.bash_profile.macports-saved_2012-08-10_at_10:00:21


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.