Hi,
i want to make alias for rm command. It should actually move the file to a directory in my home.
Say if i type
%rm abc.txt
the command should expand to
%mv abc.txt ~ashishp/trash
How should I write the alias for this?
-Ashish
Hi,
i want to make alias for rm command. It should actually move the file to a directory in my home.
Say if i type
%rm abc.txt
the command should expand to
%mv abc.txt ~ashishp/trash
How should I write the alias for this?
-Ashish
please give rep
Hi
is it possible to have such alias. Unix gurus pls reply.
-Ashish
Make your alias point to a script.
[/tmp]$ cat copy.ksh
#! /bin/ksh
(($#)) || { echo "No source file provided" ; exit 1 ; }
/bin/cp "$1" /tmp
[/tmp]$ alias copy='/path/to/copy.ksh'
And finally use the alias.
[/tmp]$ copy ~/server.xml
Make sure your copy.ksh has execute permissions.
If you dont want to use a script, then see the example at the end of page in - Examples of creating a command alias in the C shell
Thanks Vino.
I got it worked on csh using command alias rm 'mv \!^ ~ashishp/trash'.
But could not get it right on ksh.
-Ashish
Which solution ? The \!^ or the copy.ksh ?
copy.ksh worked. but \!^ did not work on ksh.
OFcourse, that construct was meant for csh only. See Alias substitution under man csh.
Thanks vino.
I found in book that one cannot have argument in alias in ksh.
The book says "C shell users should note that the Korn shell's alias feature does not support arguments in alias expansions, as C shell aliases do."
-Ashish