str ends-with

For strings.

Check if an input ends with a string.

Command Type

built-in

Signature

> str ends-with {flags} (string) ...rest

Flags

  • --ignore-case, -i: Search is case insensitive.

Parameters

  • string: The string to match.
  • ...rest: For a data structure input, check strings at the given cell paths, and replace with result.

Input/output types:

input output
string bool
list<string> list<bool>
table table
record record

Examples

Checks if string ends with ‘.rb’.

> 'my_library.rb' | str ends-with '.rb'
true

Checks if strings end with ‘.txt’.

> ['my_library.rb', 'README.txt'] | str ends-with '.txt'
╭───┬───────╮
│ 0 │ false │
│ 1 │ true  │
╰───┴───────╯

Checks if string ends with ’.RB’, case-insensitive.

> 'my_library.rb' | str ends-with --ignore-case '.RB'
true

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.