DEV Community

Evgeny Pogrebnyak
Evgeny Pogrebnyak

Posted on

1 1

Quickly inspect or sanitize PATH variable on both Windows and Linux

I think this quote about PATH environment variable is quite right:

I always get the feeling that nobody knows what a PATH is and at this point they are too afraid to ask.

PATH environment variable syntax on Windows and Linux is different, so I wrote my own utility justpath to be able to explore PATH more easily.

I did start with one line commands that show directories line by line:

echo $PATH | tr ":" "\n"
Enter fullscreen mode Exit fullscreen mode
$env:PATH.split(";")
Enter fullscreen mode Exit fullscreen mode

But what if I wanted to make a list of duplicate directories or show paths that are not valid - not too easy to make a one-liner for this behavior and this is where a Python script comes handy. After install I can do:

justpath --invalid
justpath --duplicates
Enter fullscreen mode Exit fullscreen mode

More options and documentation here at project repo.
justpath can purge invalid or duplicate paths
and make a new PATH string that you can use at your
shell startup.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay