I wrote a perl script that prints a path to a very specific file. I want to define a personal environment variables (by using setenv in .aliases file) that gives the output of this script.
For example, let's say that the file "myscript.pl" prints the path "/home/files/reports/file". Let's call the variable (that I want to define in .aliases file) 'myoutput'. I want that when I type "most $myoutput" in Unix, this file will be opened by most, and when I type "echo $myoutput", Unix will print the path.
How can I define a personal variable which value is determined by a script?
If you use bash
, you can put the following to your .bashrc
:
export myoutput=$(perl /path/to/myscript.pl)
For tcsh, use .cshrc
instead, and modify the line to
setenv myoutput `perl /path/to/myscript.pl`
You need to start a new session to make the variable exist.