Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 18590  / 1 Year ago, thu, march 9, 2023, 5:24:35

I am unable to source my ~/.profile using a bash script.



I tried:



source ~/.profile


By the way this is the script I am using



#!/bin/bash

echo Enter the shortcut, or alias, you want to use:
read SHORTTEXT
echo Now enter what text you want it to replace:
read LONGTEXT
echo "alias $SHORTTEXT='$LONGTEXT'" >> ~/.profile
echo "alias $SHORTTEXT='$LONGTEXT' was added to your profile.The alias will work after logoff/on"

More From » 12.04

 Answers
6

That script itself must be sourced for it to make changes to the current shell. If you run the script, a new instance of bash is started to interpret the commands in the script. This new instance cannot alter its parent, thus any aliases that are set in the script, dies with the script.


[#36661] Thursday, March 9, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dersol

Total Points: 78
Total Questions: 100
Total Answers: 124

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
;