> Hi,
> I have a question on using aliases in the bash shell environment.
> I created a shell script with a list of aliases (each in the format
> alias name=value) and ran the script, but none of the aliases took effect.
> Then I tried typing those same alias commands on the prompt one by one,
> and the alia worked.
This is a UNIX FAQ and not a LINUX FAQ but here's the answer.
I use tcsh as shell but the info will be exactly the same for you.
To enforce to use a particular shell, just add at the top of your
text file the following line:
#!/usr/local/bin/tcsh
(For you this will be bash instead of tcsh)
Check out if your bash config file exists. It should be placed
at ~/.bashrc (with tcsh it's ~/.cshrc).
When you want to execute a shell command, just type:
UNIX> source shell_file_to_exec
(this is right with tcsh)
With bash, just make your shell_file_to_exec file as executable
with chmod command. Then type directly its name. Don't forget
at the top to put the #!... line.
Quote:> I think the problem may be that the script file is executed in its own
> shell, and the effects are not propogated to the external world. Is there
> a way to
> "export" the aliases defined in the shell script?
Actually, an alias command should not be given with '='. It means
you should put in the file or on the command line:
UNIX> alias toto titi
Quote:> Please CC your responses to my email address. Thanks in advance,
Each time I mail a send an answer it's simulatneously posted and
e-mailed. Sometimes the replying e-mail bounces that's why I prefer
to keep such a cross posting.
Hope it helps.
PS: Never forget that LINUX is UNIX like. Try to get a good book
of UNIX (in the closest library of the closest university, if possible).
Or post directly the help question in the right news group.
--
David
/mmm\ /mmm\ /mmm\
(O o) (O O) (o o)
U U u /mmm\
||\ \\ / \\ . (- -)
oOOo__oOOo _____oOOo ___________ ______u_oOOo___
############ ######### ########### ################
(BAD ANSWER) (RETRY) (ONCE MORE) (Bored & Asleep)
+----------------------------------------------------+
| UFR IMA (French University - Grenoble) |
|I'm a netsurfer, and as such a citizen of the world!|