detect type
for strings
Infer Nushell datatype from a string.
Signature
> detect type {flags}
Flags
--prefer-filesize, -f
: For ints display them as human-readable file sizes
Input/output types:
input | output |
---|---|
string | any |
any | any |
Examples
Bool from string
> 'true' | detect type
true
Bool is case insensitive
> 'FALSE' | detect type
false
Int from plain digits
> '42' | detect type
42
Int with underscores
> '1_000_000' | detect type
1000000
Int with commas
> '1,234,567' | detect type
1234567
Float from decimal
> '3.14' | detect type
3.14
Float in scientific notation
> '6.02e23' | detect type
601999999999999995805696.0
Prefer filesize for ints
> '1024' | detect type -f
1.0 kB
Date Y-M-D
> '2022-01-01' | detect type
Sat, 1 Jan 2022 00:00:00 +0800 (3 years ago)
Date with time and offset
> '2022-01-01T00:00:00Z' | detect type
Sat, 1 Jan 2022 00:00:00 +0000 (3 years ago)
Date D-M-Y
> '31-12-2021' | detect type
Fri, 31 Dec 2021 00:00:00 +0800 (3 years ago)
Unknown stays a string
> 'not-a-number' | detect type
not-a-number