How can I do aliasing in shellscript?

#Example.sh
alias rmv 'sh Example2.sh'

when i execute exapme.sh alias name not working.
how i solve this problem??

$ cat testfile 
pwd
$
$ alias run='sh testfile'
$
$ run
/present/home/path/
$

Hi jayan,

what i need is

suppose i create another file testfile2.sh

#testfile2.sh
alias run ='sh testfile'

when i execute testfile2.sh
run alias name not working in commad promt.
what i can do??

Dont give extra spaces before and after = .. So your alias code should be alias run='sh testfile'

And if you need to put that alias in a file and run, then try with ksh shell ..

$ cat file_to_run
alias run='sh testfile'
run
$ ksh file_to_run
/present/home/path
$

# testfile2.sh
alias run='ls -l'

when i run this one also alias name not working for me.

---------- Post updated at 01:18 AM ---------- Previous update was at 01:12 AM ----------

and im using born shell

You have to execute the assigned alias within the script itself.

Once you come out of the script, kernel will defaultly unaliases it ..

Incase, if you need to retain the alias value outside the script also .. then try the below ..

$ cat file_to_run
alias run='sh testfile'
$
$ chmod 755 file_to_run
$
$ . ./file_to_run
$
$ run
/present/home/path
$
$

while iam executing . ./file_to_run
it shows /usr/bin/ . permissiondenied.

---------- Post updated at 01:42 AM ---------- Previous update was at 01:29 AM ----------

if i need to retain the alias value outside the script any other possible solutions are there...??

If you retain aliases permanently, then put an entry in corresponding profile files (based on shell) ..

Search results for setting permanent alias in unix.com .. Click here ..

but actually i dint need alising permanently.
i need it in shell script only...please suggest me solution

Execute the script as:

. ./scriptname

That is dot-space-dot-slash-scriptname.
The alias will then be retained in the current environment.