Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 5876  / 2 Years ago, sat, december 18, 2021, 11:12:07

I have a file name .test with a echo statement. Now I want to run this file from .bashrc file. What I have done so far is:



My .test file contains:



echo "hello everyone"


My .bashrc file contains:



echo "hello world"


Now what I want is to run .test file from .bashrc file and here is what I did



In .bashrc file



echo "hello world"
ENV=$(/home/narwen/.test)
echo $ENV


Now when I try to run the .bashrc file from prompt like this



. .bashrc


I get



hello world



and errors like this



XAUTHORITY=/home/niraj/.Xauthority
_=/usr/bin/env
=


Can somebody help me please?


More From » prompt

 Answers
6

Just use:



. /path/to/.test


or:



source /path/to/.test


Or, if you want to keep the output of . /path/to/.test in a variable ENV, then use:



ENV=$(. /path/to/.test)


So, please don't use spaces around the = in assignments.



And later, you can use $ENV variable something like:



echo $ENV

[#28447] Sunday, December 19, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
riffnkful

Total Points: 390
Total Questions: 123
Total Answers: 110

Location: Puerto Rico
Member since Sat, Mar 13, 2021
3 Years ago
riffnkful questions
Thu, Nov 17, 22, 04:24, 1 Year ago
Mon, Nov 28, 22, 01:40, 1 Year ago
Mon, Jul 11, 22, 13:24, 2 Years ago
Sun, Feb 5, 23, 05:06, 1 Year ago
;