1834395 Members
4052 Online
110066 Solutions
New Discussion

ALIAS to commands

 
KapilRaj
Honored Contributor

ALIAS to commands

hi all,

Is there any way to create an alias except by creating a batch file in /usr/bin ?.

When i type rm, the shell should invoke rm -i how can i do this ?.

Thanks in advance

kaps
Nothing is impossible
6 REPLIES 6
James R. Ferguson
Acclaimed Contributor

Re: ALIAS to commands

Hi:

You can put aliases in your $HOME/.profile. For instance:

alias rm='rm -i'

...JRF...
federico_3
Honored Contributor

Re: ALIAS to commands

set the environment variable ENV in your .profile:

export ENV=$HOME/.kshrc

and set in $HOME/.kshrc the alias like this:

alias rm='rm -i'


This way when a shell is invoked this file (.kshrc) is executed by the new shell and the alias you set in it will be read also if you initiate a VUE or CDE session via XDMCP.


Federico

Tracey
Trusted Contributor

Re: ALIAS to commands

If you want all users to have this alias, put the alias command in the /etc/kshrc file. This file along with the /etc/profile gets executed for all users with a kshrc shell.
KapilRaj
Honored Contributor

Re: ALIAS to commands

hi all ,

thanks for the responses....

I tried these solutions on two machines
1.C3600 HPUX 11.0 CDE

It gave me Usage rm -R bla bla error ..... did not work (I am in POSIX shell)

2.C360 HPUX 10.20 CDE

It did not gave me any error but function is not working (POSIX Shell)

Any updates

kaps
Nothing is impossible
A. Clay Stephenson
Acclaimed Contributor

Re: ALIAS to commands

Hi,

The above responses are correct just a bit incomplete. Since you indicated that you are running CDE you also need to edit your .dtprofile and set DTSOURCEPROFILE=true. This line is usually commented out in .dtprofile. This will cause .dtprofile to in turn execute .profile and the above alias definitions will be included.

Regards, Clay
If it ain't broke, I can fix that.
KapilRaj
Honored Contributor

Re: ALIAS to commands

hi all,

i tried that too, the error is something like this

once i start a windows it gives "Usage: rm [-Rfir] file ..." & rm command deletes files w/o a prompt.

Any idea why it is so ?

kaps
Nothing is impossible