This week I stumbled on a post about a command that has existed in the bash shell (and other shells like my preferred zsh) for years (originally introduced in the 80s) but that I’d never seen before.
The type command will indicate how a command would be executed.
For example:
type echo
would return
echo is a shell builtin
telling me that echo is a built-in function of this shell, as opposed to an executable binary in the file system.
Whereas doing:
type git
returns:
git is /opt/homebrew/bin/git
showing me at the git command is an executable, and the path that executable is found in.
This works for:
- Built in shell commands
- Executables
- Aliases
- Reserved Keywords
You can also get the results for multiple commands back at once. If you run type followed by a list of commands separated by spaces, it will return one line for each command specified.
For example:
type -P echo cat sail if
returns:
echo is a shell builtin
echo is /bin/echo
cat is /bin/cat
sail is an alias for [ -f sail ] && bash sail || bash vendor/bin/sail
![➜ ~ type echo cat sail if echo is a shell builtin cat is /bin/cat sail is an alias for [ -f sail ] && bash sail || bash vendor/bin/sail if is a reserved word](https://www.shawnhooper.ca/wp-content/uploads/2025/10/Screenshot-2025-10-10-at-11.41.47-AM.png)
@shooper Incredible!
Wish I'd known about this while I was migrating from MAMP to Valet… So much time spent trying to figure out what was being loaded by “php”, "mysql” etc. And I have so many aliases banging around that sometimes I don't even realized I've overwritten a build-in command 😅
I should tattoo this on the back of my hand 🤔
Remote Reply
Original Comment URL
Your Profile
Next to a tattoo of the tar command’s parameters!
@shooper HAHA omg just yesterday I did some happy go lucky `gunzip xyz.gz` forgetting that that would remove the file 💀 💀 💀
Remote Reply
Original Comment URL
Your Profile