3

I'm working on Fedora 18 with tcsh on a network with a lot of pre-defined aliases. I'm adding my own personal aliases as well, but I want to be able to display these in a separate list.

Right now I have a .cshrc file that loads alias definitions from a .alias file. This is the file with the pre-defined aliases. I thought to create a second file named .myalias, put my personal aliases there, and have .cshrc load that as well. That works fine.

Sadly, using the alias command only lists ALL defined aliases. I want to list only my personal aliases from the .myalias file, but in the same format as the output from the alias command. Is there a way to do this?

1

No I do not believe there is any way to distinguish between the aliases coming from the system or from your .myaliases file. I typically use grep or less and pipe the output of the alias command to either to find what I want.

Additionally I'd typically grep through the contents of a file such as .myalias to find what I'm looking for.

Example

Say I have the following aliases.

$ alias
egrep   egrep --color=auto
fgrep   fgrep --color=auto
grep    grep --color=auto
l.  ls -d .* --color=auto
ll  ls -l --color=auto
ls  ls --color=auto
mc  source /usr/libexec/mc/mc-wrapper.csh
vi  vim
which   alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde

I'd find the definition of fgrep like so:

$ alias | grep "^fgrep"
fgrep   fgrep --color=auto

You can also use less to give yourself a view of multiple pages of aliases that you can then move back and forth through using the arrow keys or you can search through the output using the forward slash (/) followed by whatever string you're looking for.

$ alias | less
  • 1
    Great, the grep tip specifying a string really helped. I used that and a naming convention so that all my aliases start with "mc". Then $ alias | grep "^mc *" works for me. Thanks! – M. Carney Nov 5 '13 at 11:54
  • @M.Carney - glad to hear it helped. Thanks for the Q! – slm Nov 5 '13 at 12:49

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.