Home Explore Blog CI



nushell

1st chunk of `commands/docs/any.md`
fa1f34a392a405089d62b6890e332a33e501b2d915519ef80000000100000540
---
title: any
categories: |
  filters
version: 0.104.0
filters: |
  Tests if any element of the input fulfills a predicate expression.
usage: |
  Tests if any element of the input fulfills a predicate expression.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `any` for [filters](/commands/categories/filters.md)

<div class='command-title'>Tests if any element of the input fulfills a predicate expression.</div>

## Signature

```> any {flags} (predicate)```

## Parameters

 -  `predicate`: A closure that must evaluate to a boolean.


## Input/output types:

| input     | output |
| --------- | ------ |
| list\<any\> | bool   |
## Examples

Check if a list contains any true values
```nu
> [false true true false] | any {}
true
```

Check if any row's status is the string 'DOWN'
```nu
> [[status]; [UP] [DOWN] [UP]] | any {|el| $el.status == DOWN }
true
```

Check that any item is a string
```nu
> [1 2 3 4] | any {|| ($in | describe) == 'string' }
false
```

Check if any value is equal to twice its own index
```nu
> [9 8 7 6] | enumerate | any {|i| $i.item == $i.index * 2 }
true
```

Check if any of the values are odd, using a stored closure
```nu
> let cond = {|e| $e mod 2 == 1 }; [2 4 1 6 8] | any $cond
true
```

Title: any
Summary
The `any` command in Nushell tests if any element of a list fulfills a given predicate expression. It takes a closure as an argument, which must evaluate to a boolean for each element. The command returns `true` if at least one element satisfies the predicate, and `false` otherwise. Several examples are provided to illustrate its usage with different predicates.