Notes on the ‘type’ Command in Bash — Not Something you’d Expect coming from Python and Powershell.

Pavol Kutaj
2 min readOct 20, 2021

The aim of this page📝is to present the type command in bash, noting there is no object model in bash that one may take for granted coming from Python & Powershell.

1. notes

  • note that type in bash does not tell you the type of variable you have - like type(<name>) in Python

Bash doesn’t have types in the same way as Python (although I would say that Python has classes rather than types). But bash variables do have attributes that are given (mostly) through declare, but the range of attributes is fairly small. You can find an attribute using declare -p, for example, declare -i creates an integer

  • coming from posh/python then, a weird thing may happen
<!-- PYTHON -->
>>> greeting = "hello"
>>> type(greeting)
<class 'str'>

<!-- POSH -->
>>> $greeting = "hello"
>>> $greeting.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object

<!-- BASH -->
>>> greeting="hello"
>>> echo $greeting
>>> type $greeting
-bash: type: hello: not found
  • there are only 5 possible “types” that the type command returns
  1. alias → command is shell alias
  2. keyword → command is shell reserved word
  3. function → command is shell function
  4. builtin → command is shell builtin
  5. file → command is disk file
  • if it is a function
$ prnt(){
> echo "you passed me" $*
> }
$ prnt fd fdsfsd fs fdsf
you passed me fd fdsfsd fs fdsf
$ type prnt
prnt is a function
prnt ()
echo "you passed me" $*
  • in posh, type is a built-in alias for Get-Content aka cat command

2. links



Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at with a passion for cloud infrastructure/terraform/python/docs. More at