Just run your shell script preceded by “.
” (dot space).
This causes the script to run the instructions in the original shell. Thus the variables still exist after the script finish
Ex:
cat setmyvar.sh
export myvar=exists
. ./setmyvar.sh
echo $myvar
exists
More Related Contents:
- Can I export a variable to the environment from a Bash script without sourcing it?
- What is the exact meaning of IFS=$’\n’?
- LINES and COLUMNS environmental variables lost in a script
- Is there a way to get my emacs to recognize my bash aliases and custom functions when I run a shell command?
- Reading quoted/escaped arguments correctly from a string
- Can a shell script set environment variables of the calling shell? [duplicate]
- How to add a progress bar to a shell script?
- What is the purpose of “&&” in a shell command?
- How can I remove the extension of a filename in a shell script?
- While-loop subshell dilemma in Bash
- How do I escape the wildcard/asterisk character in bash?
- How can I count all the lines of code in a directory recursively?
- How does Ctrl-C terminate a child process?
- Running multiple commands in one line in shell
- printf in bash: “09” and “08” are invalid numbers, “07” and “06” are fine
- Concatenating multiple text files into a single file in Bash
- How to Batch Rename Files in a macOS Terminal?
- How to pass arguments to Shell Script through docker run
- How do I pause my shell script for a second before continuing?
- How do you echo a 4-digit Unicode character in Bash?
- Print a character repeatedly in bash [duplicate]
- Forking / Multi-Threaded Processes | Bash
- How to remove filename prefix with a Posix shell
- What does ” 2>&1 ” mean?
- Why do I get “/bin/sh: Argument list too long” when passing quoted arguments?
- How do I check if a directory exists or not in a Bash shell script?
- Why isn’t DYLD_LIBRARY_PATH being propagated here?
- shell script respond to keypress
- Use GNU find to show only the leaf directories
- Get the name of the caller script in bash script