Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

format bits for conversions

Convert value to a string of binary data represented by 0 and 1.

Signature

> format bits {flags} ...rest

Parameters

  • ...rest: For a data structure input, convert data at the given cell paths.

Input/output types:

inputoutput
binarystring
intstring
filesizestring
durationstring
stringstring
boolstring
tabletable
recordrecord

Examples

convert a binary value into a string, padded to 8 places with 0s

> 0x[1] | format bits
00000001

convert an int into a string, padded to 8 places with 0s

> 1 | format bits
00000001

convert a filesize value into a string, padded to 8 places with 0s

> 1b | format bits
00000001

convert a duration value into a string, padded to 8 places with 0s

> 1ns | format bits
00000001

convert a boolean value into a string, padded to 8 places with 0s

> true | format bits
00000001

convert a string into a raw binary string, padded with 0s to 8 places

> 'nushell.sh' | format bits
01101110 01110101 01110011 01101000 01100101 01101100 01101100 00101110 01110011 01101000