Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove particular path in cygwin

Tags:

path

cygwin

I want to ask how to remove path in cygwin. Let's say I have 3 paths:

PATH=path1:path2:path3

I want to remove path2 so it will be:

PATH=path1:path3

But actually i have a lot of path inside and it will painful to rewrite it manually. Any suggestion?

like image 602
kreamik Avatar asked Nov 15 '25 20:11

kreamik


1 Answers

A simple solution is to use the bash or csh command-line:

   export PATH=`echo $PATH | sed s/:path2//`

But this will only work 99.9% of the time. To handle the edge cases, such as when path2 is at the start, or when it is part of another path, you'll need:

   export PATH=`echo $PATH | sed "s/:path2:/:/g;s/^path2://;s/:path2$//"`
like image 137
Joseph Quinsey Avatar answered Nov 17 '25 10:11

Joseph Quinsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!