0

Please advice how to do the following magic ( I have linux red-hat machine – 5.4 )

I created the script in the following path:

        /usr/cti/my_scripts/MAGIC.bash

I want to run this script from evry dir in my linux by alias name – M

For example

Under /tmp or /usr/or /var or evry dir When I type M , then it will run the script /usr/cti/my_scripts/MAGIC.bash

Please advice what the steps that need to configure in my linux machine?

EXAMPLE

under /usr

when I enter - M

then it will run the script - /usr/cti/my_scripts/MAGIC.bash

5

Edit your "~/.bashrc" or "~/.bash_profile" to include the alias command.

Add this line to your profile:

alias M="/usr/cti/my_scripts/MAGIC.bash"
2

If you have ruby installed, use aka to create permanent alias on the fly.

0

You could use an alias in .bashrc.
But that works only from interactive shells, not in shell scripts.

To make it work in scripts too, you can make a symlink in a directory that is in PATH, for example in $HOME/bin directory. (Create it if missing, could be that it is included into PATH automatically on next login.)

cd ~/bin
ln -s /path/to/M-script.sh M

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.