str lpad

Left-pad a string to a specific length

Signature

> str lpad ...rest --length --character

Parameters

  • ...rest: optionally check if string contains pattern by column paths
  • --length {int}: length to pad to
  • --character {string}: character to pad with

Examples

Left-pad a string with asterisks until it's 10 characters wide

> 'nushell' | str lpad -l 10 -c '*'

Left-pad a string with zeroes until it's 10 character wide

> '123' | str lpad -l 10 -c '0'

Use lpad to truncate a string

> '123456789' | str lpad -l 3 -c '0'

Use lpad to pad Unicode

> '▉' | str lpad -l 10 -c '▉'