Services
Blog
Français
A variable looks like this:
export FOO=barTo get a variable in your interactive shell, source the script that contains it as such:
source script_that_contains_FOO
echo $FOOA function looks like this:
function foo() {
echo foo
}To run a function in your interactive shell, source the script and call the function like this:
source script_that_contains_foo
fooTo debug something that’s wrapped in a bash function or script, set the -x option. To de-activate debugging, set +x. Example:
[env] 04/02 2014 02:17:26 jpic@etta /home/jpic
$ source script_that_contains_foo
[env] 04/02 2014 02:17:29 jpic@etta /home/jpic
$ set -x; foo; set +x
+ foo
+ echo bar
bar
+ set +xLines prefixed with a + sign are those that are executed by bash. Lines without + prefix correspond to output.
Ok, now you can use shell scripting like an interactive framework.