My PATH Variable is a Mess

Introduction

When you install a program, it often asks you to add a PATH to your shell config file. I do it blindly thinking, “This tool is cool. I want to use it NOW!” After some time you find your PATH variable is a mess. A lot of duplication or triplication of PATHs. It is time to clean it up.

Check your PATH

The following command substitutes colons with new lines, sorts, counts the number of unique PATH occurrences, and displays:

$ echo $PATH | sed 's/:/\n/g' | sort | uniq -c

The part of my output from echo $PATH | sed ‘s/:/\n/g’ | sort | uniq -c. Image by Author.

Do you have any PATH more than once? If so, read on!

Website

Tags: path variable