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

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

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

https://stackoverflow.com/a/29840856/11082684

<!-- 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
hello
>>> type $greeting
-bash: type: hello: not found
  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
$ 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" $*
}

2. links

Technical Support Engineer of Behavioural Data Platform (Snowplow Analytics). On comparison of programming languages, history of computing, and raw playbooks.