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

str trim for strings

Trim whitespace or specific character.

Signature

> str trim {flags} ...rest

Flags

  • --char, -c {string}: character to trim (default: whitespace)
  • --left, -l: trims characters only from the beginning of the string
  • --right, -r: trims characters only from the end of the string

Parameters

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

Input/output types:

inputoutput
list<string>list<string>
recordrecord
stringstring
tabletable

Examples

Trim whitespace

> 'Nu shell ' | str trim
Nu shell

Trim a specific character (not the whitespace)

> '=== Nu shell ===' | str trim --char '='
 Nu shell

Trim whitespace from the beginning of string

> ' Nu shell ' | str trim --left
Nu shell

Trim whitespace from the end of string

> ' Nu shell ' | str trim --right
 Nu shell

Trim a specific character only from the end of the string

> '=== Nu shell ===' | str trim --right --char '='
=== Nu shell