W3cubDocs

/Nushell

any for filters

Tests if any element of the input fulfills a predicate expression.

Signature

> any {flags} (predicate)

Parameters

  • predicate: a closure that must evaluate to a boolean

Input/output types:

input output
list<any> bool
table bool

Examples

Check if any row's status is the string 'DOWN'

> [[status]; [UP] [DOWN] [UP]] |any {|el| $el.status==DOWN }
true

Check that any item is a string

> [1234] |any {|| ($in|describe) =='string' }
false

Check if any value is equal to twice its own index

> [9876] |enumerate|any {|i| $i.item==$i.index*2 }
true

Check if any of the values are odd, using a stored closure

>letcond= {|e| $emod2==1 }; [24168] |any$cond
true

Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/any.html