0

I have a working shell script that I would like to add as a command mein-befehl referring to that post:

#!/bin/bash
original_string="$1"
string_to_replace_with='7'
result_string="${original_string/6/$string_to_replace_with}"
echo "$result_string"

so I have created the bin directory with

mkdir ~/bin

and placed my script file inside there. Then I have made it executable:

chmod +x ~/bin/mein-befehl

After that I have exportet the path:

export PATH=$PATH:~/bin

Updating by

sudo ~/.bashrc

returns the following issue to me:

sudo: /home/martin/.bashrc: command not found

running

~/.profile

is accepted.

So when I restart the terminal and type

mein-befehl "2016"

returns a command not found issue.

Question: I have followed exactly the steps mentioned in the post. Other sources online point out similiar things. What can I still have done wrong?

my $PATH variable contains:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/martin/bin
jublikon
  • 121
  • 4
    export PATH=$PATH:~/bin doesn't add to your PATH persistently unless you add it to your ~/.bashrc file. Also, your sudo ./bashrc step should probably have been source ~/.bashrc or . ~/.bashrc – steeldriver Apr 27 '17 at 12:00
  • running 'source ~/.bashrc' made it. I have read somewhere in the linked post that running '~/.profile' should be enough. Can you explain the difference, please? – jublikon Apr 27 '17 at 12:03
  • @steeldriver Enough for an answer, isn’t it? – Melebius Apr 27 '17 at 12:10

0 Answers0