found ls binary using whereis but can't find ll why ? How to find where ll binary loacted ?
I found "ls" binary using "whereis" but can't find "ll"
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
But can't find ll :
$ whereis ll
ll:
found ls binary using whereis but can't find ll why ? How to find where ll binary loacted ?
I found "ls" binary using "whereis" but can't find "ll"
$ whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
But can't find ll :
$ whereis ll
ll:
ll
is not a binary but an alias of the ls -alF
command.
Check the .bashrc
file :
$ alias ll
alias ll='ls -alF'
type
, which is a built-in in most shells, or which
(/usr/bin/which
) instead of whereis
. Differently from whereis
, those will detect aliases etc.
– kos
Nov 05 '15 at 16:40
type
, yes, but which
will not detect aliases. As you note, it's an executable /usr/bin/which
, which does not have access to your shell aliases.
– wchargin
Nov 06 '15 at 02:59
zsh
an in zsh
which
is a built-in (and detects aliases). /usr/bin/which
won't detect aliases; which
in zsh
(and I guess in other shells which have it as a built-in as well) will detect aliases.
– kos
Nov 06 '15 at 03:57
alias | which -i
, which is itself often made an alias, as in alias which="alias | which -i"
. Unfortunately, the version in Ubuntu seems to lack this feature, so while using which can apply generally, it doesn't here :-(
– John O'M.
Nov 06 '15 at 13:06
As noted by kos in the comments, you should use the bash built-in type
command which, unlike whereis
, is also aware of aliases and shell built-ins:
$ type ll ls cd
ll is aliased to `ls -alF'
ls is hashed (/bin/ls)
cd is a shell builtin
(For the meaning of "hashed", see this question on unix.SE.)
testfunc() { echo 'Hi!'; }; type testfunc
.
– Ruslan
Nov 06 '15 at 09:43
Many users like short cuts and this is what an alias is, a shortcut option for users.
Scripts should not use shortcuts, that is not a portable design, as you found out, these alias commands are not consistently defined.
Easiest answer to meet your need, assuming the use of 'll' is repeated:
Within the script, define the alias ll='ls -l', before referencing the command, then the use of 'll' will work throughout this script.
#!/bin/bash
alias ll='ls -alF'
... (rest of the script)
Better Answer: better to use the full command in the script, provides documentation. Never use an alias in a script that others have to use.
{}
button. Or manually indent each code line with 4 spaces. That's the Markdown syntax used here on StackExchange. See http://askubuntu.com/help/formatting to learn more.
– Byte Commander
Nov 05 '15 at 17:43
type -a ls ll
– glenn jackman Nov 05 '15 at 17:10