Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

environment variable

41 views
Skip to first unread message

Smith

unread,
Jun 24, 2017, 4:49:35 PM6/24/17
to
Hello to all,
I wanted to ask you how I could delete a line of an environment variable
(PATH)

~/Scaricati/pycharm-2017.1.4/bin$ echo $PATH | sed s/:/'\n'/g
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
/path/to/my/program ---> linea da eliminare
/home/dbruno/Scaricati/pycharm-2017.1

Do I unset PATH delete all content?
I have not tried yet

I downloaded pycharm and wanted to make it executable from the command
line without accessing the bin folder and launch the bash script:

dbruno@dbruno:~/Scaricati/pycharm-2017.1.4$ ls -la
total 48
drwxrwxr-x 10 dbruno dbruno 4096 giu 24 10:23 .
drwxr-xr-x 18 dbruno dbruno 4096 giu 24 10:23 ..
drwxrwxr-x 2 dbruno dbruno 4096 giu 24 10:25 bin
-rw-r--r-- 1 dbruno dbruno 14 giu 13 14:48 build.txt
drwxrwxr-x 2 dbruno dbruno 4096 giu 24 10:23 debug-eggs
drwxrwxr-x 2 dbruno dbruno 4096 giu 24 10:23 help
drwxrwxr-x 17 dbruno dbruno 4096 giu 24 10:23 helpers
-rw-r--r-- 1 dbruno dbruno 1887 giu 13 14:48 Install-Linux-tar.txt
drwxrwxr-x 4 dbruno dbruno 4096 giu 24 10:23 jre64
drwxrwxr-x 4 dbruno dbruno 4096 giu 24 10:23 lib
drwxrwxr-x 2 dbruno dbruno 4096 giu 24 10:23 license
drwxrwxr-x 52 dbruno dbruno 4096 giu 24 10:23 plugin

:~/Scaricati/pycharm-2017.1.4/bin$ ls -la
total 7120
drwxrwxr-x 2 dbruno dbruno 4096 giu 24 10:25 .
drwxrwxr-x 10 dbruno dbruno 4096 giu 24 10:23 ..
-rw-rw-r-- 1 dbruno dbruno 0 giu 24 20:18 0M?+
-rwxr-xr-x 1 dbruno dbruno 221 giu 13 14:48 format.sh
-rwxr-xr-x 1 dbruno dbruno 23072 giu 13 14:48 fsnotifier
-rwxr-xr-x 1 dbruno dbruno 29648 giu 13 14:48 fsnotifier64
-rwxr-xr-x 1 dbruno dbruno 26453 giu 13 14:48 fsnotifier-arm
-rw-r--r-- 1 dbruno dbruno 10804 giu 13 14:48 idea.properties
-rwxr-xr-x 1 dbruno dbruno 272 giu 13 14:48 inspect.sh
-rw-r--r-- 1 dbruno dbruno 3449944 giu 13 14:48 libyjpagent-linux64.so
-rw-r--r-- 1 dbruno dbruno 3679036 giu 13 14:48 libyjpagent-linux.so
-rw-r--r-- 1 dbruno dbruno 2236 giu 13 14:48 log.xml
-rwxr-xr-x 1 dbruno dbruno 410 giu 13 14:48 printenv.py
-rw-r--r-- 1 dbruno dbruno 329 giu 13 14:48 pycharm64.vmoptions
-rw-r--r-- 1 dbruno dbruno 10281 giu 13 14:48 pycharm.png
-rwxr-xr-x 1 dbruno dbruno 6860 giu 13 14:48 pycharm.sh
-rw-r--r-- 1 dbruno dbruno 337 giu 13 14:48 pycharm.vmoptions
-rwxr-xr-x 1 dbruno dbruno 590 giu 13 14:48 restart.py

You can help me ?

Thank you

Michael F. Stemper

unread,
Jun 24, 2017, 5:15:11 PM6/24/17
to
On 2017-06-24 15:49, Smith wrote:
> Hello to all,
> I wanted to ask you how I could delete a line of an environment variable
> (PATH)
>
> ~/Scaricati/pycharm-2017.1.4/bin$ echo $PATH | sed s/:/'\n'/g
> /usr/local/sbin
> /usr/local/bin
> /usr/sbin
> /usr/bin
> /sbin
> /bin
> /usr/games
> /usr/local/games
> /snap/bin
> /path/to/my/program ---> linea da eliminare
> /home/dbruno/Scaricati/pycharm-2017.1
>
> Do I unset PATH delete all content?

That would not be a good idea.

Although this seems to be more of a bash question than a python
question, I'll take a crack at it.

The first question is: do you want to eliminate that directory from your
$PATH forever and ever, or do you just want to eliminate it in some
shell instances?

If the first is true, find out where it's being added to your $PATH,
such as ~/.profile or ~/.bashrc and comment out that line.

If the second is true, you could clear it out in real time, with a
little something like:
. export PATH=`echo $PATH | sed 's,:/path/to/my/program,,'`

This has not been tested, but is reasonably close to what's needed. Note
that you need the period "." at the beginning to make sure that this
happens in the current shell.


> I downloaded pycharm and wanted to make it executable from the command
> line without accessing the bin folder and launch the bash script:

But, here's the big question. How does having "/path/to/my/program" in
your $PATH variable prevent you from doing that? The simple answer is
that it doesn't.

You might want to ADD something to your $PATH, such as
"~/Scaricati/pycharm-2017.1.4/bin", but taking something out will not
do what you want.

Another approach would be to ADD something to your .bash_aliases file,
such as:

pych()
{
~/Scaricati/pycharm-2017.1.4/bin/pycharm.sh $*
}

Then, you can type "pych" at the command line, and bash will interpret
it as the above command, including arguments.

Two words of caution here:
1. I haven't tested this code, either.
3. If pycharm does not know its location (which is not necessarily
the current directory), it might not be able to find the many
accessory files that are there.


--
Michael F. Stemper
I feel more like I do now than I did when I came in.

Gene Heskett

unread,
Jun 24, 2017, 6:51:42 PM6/24/17
to
export PATH=

but be prepared to type the full path to anything you want to run. It a
PITA, or a cast iron bitch or whatever definition fits.

Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

Steve D'Aprano

unread,
Jun 24, 2017, 9:03:29 PM6/24/17
to
On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote:

> On Saturday 24 June 2017 16:49:25 Smith wrote:
>
>> Hello to all,
>> I wanted to ask you how I could delete a line of an environment
>> variable (PATH)
[...]

> export PATH=
>
> but be prepared to type the full path to anything you want to run. It a
> PITA, or a cast iron bitch or whatever definition fits.

Are you serious? The OP asked how to delete *one line* from an environment
variable, and you respond by deleting them all?

"The ashtray in my car is full, how do I clean it?"

"Throw the car away and walk everywhere."




--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

Gene Heskett

unread,
Jun 24, 2017, 9:46:39 PM6/24/17
to
On Saturday 24 June 2017 21:03:18 Steve D'Aprano wrote:

> On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote:
> > On Saturday 24 June 2017 16:49:25 Smith wrote:
> >> Hello to all,
> >> I wanted to ask you how I could delete a line of an environment
> >> variable (PATH)
>
> [...]
>
> > export PATH=
> >
> > but be prepared to type the full path to anything you want to run.
> > It a PITA, or a cast iron bitch or whatever definition fits.
>
> Are you serious? The OP asked how to delete *one line* from an
> environment variable, and you respond by deleting them all?
>
$PATH is a single line in the env. The OP asked how to delete it, so I
told him. If he had asked how to get rid of a single piece of the $PATH,
then my answer would have been longer and more precise.

> "The ashtray in my car is full, how do I clean it?"

Take it out and dump it. Put it back in. Or leave it out, the car will
not care, it will still haul your butt as long as theres oil in the
engine and gas in the tank.

> "Throw the car away and walk everywhere."

This is one of those posts that I should have ignored as this list has an
abundance of standup comics anyway.
>
>
>
>
> --
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and
> sure enough, things got worse.


Cameron Simpson

unread,
Jun 25, 2017, 12:48:04 AM6/25/17
to
On 24Jun2017 21:31, Gene Heskett <ghes...@shentel.net> wrote:
>On Saturday 24 June 2017 21:03:18 Steve D'Aprano wrote:
>> On Sun, 25 Jun 2017 08:39 am, Gene Heskett wrote:
>> > On Saturday 24 June 2017 16:49:25 Smith wrote:
>> >> Hello to all,
>> >> I wanted to ask you how I could delete a line of an environment
>> >> variable (PATH)
>>
>> [...]
>> > export PATH=
>> > but be prepared to type the full path to anything you want to run.
>> > It a PITA, or a cast iron bitch or whatever definition fits.
>>
>> Are you serious? The OP asked how to delete *one line* from an
>> environment variable, and you respond by deleting them all?
>>
>$PATH is a single line in the env. The OP asked how to delete it, so I
>told him. If he had asked how to get rid of a single piece of the $PATH,
>then my answer would have been longer and more precise.

English is clearly the OP's second language, and his post was pretty clear that
he did indeed want to remove a single item from the things named in $PATH. He
even provided example code showing exactly what he wanted to remove, and which
demonstrated that he knew it was a colon separated string, which he was
presenting as lines for purposes of clarity.

Cheers,
Cameron Simpson <c...@zip.com.au>
0 new messages