Celeb Glow
updates | March 08, 2026

Can I "export" an alias to the SHELL that invoked a script?

I'm trying to write a utility script that defines certain aliases.
My SHELL is tcsh (can't change that).

I tried the following

#!/bin/tcsh
alias log 'less ~/logs/log.`date '+%Y%m%d'`''

Then I run it like this:

./myscript
log

The output I get is: log: Command not found.

Naturally if I run it like this:

source myscript
log

Everything is fine.

Any way to do it without specifying source ...?

2

1 Answer

You can't. By running your script you execute a new shell. Aliases will not be seen by the parent process.

The only way as pointed out is using source so that the current shell processes your script file (without starting a new process).

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy