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
trueBool is case insensitive
> 'FALSE' | detect type
falseInt from plain digits
> '42' | detect type
42Int with underscores
> '1_000_000' | detect type
1000000Int with commas
> '1,234,567' | detect type
1234567Float from decimal
> '3.14' | detect type
3.14Float in scientific notation
> '6.02e23' | detect type
601999999999999995805696.0Prefer filesize for ints
> '1024' | detect type -f
1.0 kBDate 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