The command alias lists the active aliases. But it does this in a way that is different from how to set the alias:

% alias foo 'bar \!*'
% alias baz quux xyzzy
% alias corge 'grault \
garply  (quux xyzzy)'
% alias
baz     (quux xyzzy)
corge   grault 
garply  (quux xyzzy)
foo     bar !*

How can I convert the existing aliases to the commands that would build the alias (sort of the command alias but in reverse)?


AFAIK, there is no way to do this in csh or tcsh.

POSIX compatible alias implementations (e.g. those in ksh or the Bourne Shell) offer "alias -p" to list aliases in a way that allows the result to be fed into the shell again.

You may try to switch to a different shell or to ask the maintainers of csh (this would be rather tcsh) to add support for alias -p.

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.