How alias in Bash can be in the forked sub process Bash as get failed on:

alias al='echo hello '
$ al foobar
hello foobar

$ alias al='echo hello ' ; bash
$ al
bash: al: command not found

How to have it on the latter Bash as exactly functional as is ?


1 Answer 1


AFAIK, already defined aliases in a parent-shell can't be exported(made available) to sub-shells/processes but can be made available to sub-shells by sourcing a file in which they are defined e.g. ~/.bashrc ... Which means, in other words, redefining them in the sub-shells.

Functions, on the other hand, can be exported with export -f name ... So, you can use a function instead like so:

$ function al { echo "hello $1"; }; export -f al; bash
$ al
$ al again
hello again

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .