Quantcast
Viewing all articles
Browse latest Browse all 4871

Beginners • Re: I found a new command whereis

My usual command for this is "type", as it's a "shell builtin" for bash that guarantees you the same search as if you just typed the command, and knows about anything else (e.g. shell aliases, builtins, functions, etc) that might get between your command line input and the result.

Code:

murph@raspberrypi:~ $ type typetype is a shell builtinmurph@raspberrypi:~ $ type lsls is aliased to `ls --color=auto'murph@raspberrypi:~ $ type quotequote is a functionquote (){    local quoted=${1//\'/\'\\\'\'};    printf "'%s'" "$quoted"}murph@raspberrypi:~ $ type bashbash is /usr/bin/bashmurph@raspberrypi:~ $
In general, all of the other commands can give you slightly misleading results, as they don't account for the all of the shell's behaviour, just PATH. You do still need them for some things, e.g. "which ls" is required after "type ls" to find the path to the executable beneath the alias. As far as I can remember, type pre-dates bash, and was present in the ancient /bin/sh for AT&T Unix System V (aka, the Bourne shell, which was the basis for the independent rewrite as bash, the Bourne Again SHell).

Statistics: Posted by Murph9000 — Sun Sep 15, 2024 9:36 pm



Viewing all articles
Browse latest Browse all 4871

Trending Articles