Monday, February 26, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 486  / 2 Years ago, wed, january 19, 2022, 1:52:36

Context


After exporting a script to ~/bin/script_name and running it successfully from the CLI at an arbitrary place with: script_name, I have updated the content of the script. However, this update is not reflected in the behaviour.


Old content:


#!/bin/bash
echo "Old world"

New content:


#!/bin/bash
echo "Hello world"

I saved the file, and reopened it, and it shows the new content.


Expected output:


Hello world

Actual output:


Old world

Question


How can I ensure the renewed content from the ~/bin/script_name is used when I call it from an arbitrary location using: script_name?


Attempts


First I tried closing and re-opening the terminal. Then I tried rebooting, both show the same, unexpected (to me) behaviour.


Additional information


Ubuntu 22.10, and the $PATH content is:


/home/name/miniconda/envs/snncompare/bin:/home/name/miniconda/condabin:/home/name/.local/bin:/home/name/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

More From » command-line

 Answers
3

You have a copy of the script located at /home/name/.local/bin/script_name which you did not update. This variation of the script are found first in the path.


Hence, when you run it from an arbitrary location, you get the old script.


Remove the script from this location:


rm /home/name/.local/bin/script_name

And only have your script in one location. Otherwise, you'll create a mess for yourself.


[#8] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulerio

Total Points: 172
Total Questions: 124
Total Answers: 109

Location: Hungary
Member since Thu, Aug 6, 2020
4 Years ago
fulerio questions
Thu, May 6, 21, 07:07, 3 Years ago
Sat, Dec 18, 21, 21:21, 2 Years ago
Wed, May 18, 22, 14:05, 2 Years ago
;