In bash on redhat I have to use type -P, and not which, if i want the correct answer. No aliases or functions are concerned. Dr Eval, which "which"? Which Red Hat? Mikel RH7. GNU which v2. HalosGhost 4, 10 10 gold badges 30 30 silver badges 40 40 bronze badges. Meitham Meitham 5 5 bronze badges. Try the following: which --skip-alias vim. SiegeX SiegeX 7, 3 3 gold badges 32 32 silver badges 23 23 bronze badges.
This works on Bash, but not on Zsh I really didn't think this was going to be shell-dependent. This made me realize that which is actually a shell built-in and not a regular Unix utility as I had assumed.
So I should edit my question and specify Zsh. Thanks for pointing this out to me! It is a shell script, and part of debianutils, so works on zsh. However, --skip-alias is not an option the which on Debian. Are there different varieties of which floating around?
This does not apppear to be a standardized command. Faheem Mitha: It is a zsh builtin. See man zshbuiltins. Equivalent to whence -c. Yeah on Xubuntu's bash , it is not a built-in and doesn't have the --skip-alias option. As a result which which shows the alias, but command which which shows the executable!
Another alternative is command which vim , which works the same way in both zsh and bash E. Zee Alexander Zee Alexander 5 5 silver badges 6 6 bronze badges. Ah fair enough. Both type and which behave differently according to your shell type. More from ZSH manual. Simba Simba 1, 10 10 silver badges 12 12 bronze badges. You can see this from the terminal just using cat. I don't know if that answers your question though. Do you really want to open the alias file itself? Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Reading Alias files Ask Question. Asked 11 years, 7 months ago. Active 11 years, 6 months ago. Viewed 3k times. Improve this question. Girish Kolari Girish Kolari 2, 2 2 gold badges 23 23 silver badges 34 34 bronze badges. Are you sure you're not looking at a symbolic link?
Alias files and symbolic links are two different things; an alias file is a regular file containing alias data, whereas a symbolic link is a separate kind of file.
I guess he means this. Add a comment. If you enclose value within single quotation marks, variables are not expanded until the alias is used. The following example illustrates the difference. The PWD keyword variable holds the pathname of the working directory. Max creates two aliases while he is working in his home directory. Because he uses double quotation marks when he creates the dirA alias, the shell substitutes the value of the working directory when he creates this alias.
The alias dirA command displays the dirA alias and shows that the substitution has already taken place:. After creating the dirA and dirB aliases, Max uses cd to make cars his working directory and gives each of the aliases as a command.
The alias he created using double quotation marks displays the name of the directory he created the alias in as the working directory which is wrong. In contrast, the dirB alias displays the proper name of the working directory:.
The shell checks only simple, unquoted commands to see if they are aliases. Commands given as relative or absolute pathnames and quoted commands are not checked. When you want to give a command that has an alias but do not want to use the alias, precede the command with a backslash, specify the command's absolute pathname, or give the command as.
The following alias allows you to type r to repeat the previous command or r abc to repeat the last command line that began with abc :. If you use the command ls -ltr frequently, you can create an alias that substitutes ls -ltr when you give the command l :. Another common use of aliases is to protect yourself from mistakes. The following example substitutes the interactive version of the rm utility when you enter the command zap :. The -i option causes rm to ask you to verify each file that would be deleted, thereby helping you avoid deleting the wrong file.
0コメント