Bourne: How to invoke an alias from within a shell script
If I type in the alias in the command line, it runs
If I insert that same alias into my shell script and run the shell script, the alias is not invoked.
Help please.
Bourne: How to invoke an alias from within a shell script
If I type in the alias in the command line, it runs
If I insert that same alias into my shell script and run the shell script, the alias is not invoked.
Help please.
Exporting aliases is shaky at best, and what can be achieved can only be achieved with the Korn shell, not Bourne.
See this.
Here is an excerpt...
Exporting aliases works in much the same way as exporting variables with export. But, ksh will only export an alias to another shell that is not a separate invocation of ksh (an exported alias will survive a fork(2), but not an exec(2)). Exported aliases are available to subshells, for example, ( prog ), and to shell scripts that do not start with #!/bin/*.
You can export aliases interactively or from within your .profile or .kshrc. To do so type, or add to the appropriate file:
alias -x who='who | sort'
Then, when you type alias or alias -x, who=who | sort is shown.
Cheers
ZB
This is quite old thread though, but stillI want to know about few concepts here, like what is meant by:
Regards,
Tayyab