nushell/docs/commands/where.md
2019-12-02 11:02:58 -08:00

2.3 KiB

where

This command filters the content of a table based on a condition passed as a parameter, which must be a boolean expression making use of any of the table columns. Other commands such as ls are capable of feeding where with their output through pipelines.

Usage

> [input-command] | where [condition]

Examples

> ls | where size > 4kb
━━━┯━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━┯━━━━━━━━━━━━━
 # │ name       │ type │ size    │ created     │ accessed    │ modified 
───┼────────────┼──────┼─────────┼─────────────┼─────────────┼─────────────
 0 │ Cargo.lock │ File │ 87.2 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago 
 1 │ README.md  │ File │ 19.5 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago 
 2 │ Cargo.toml │ File │  4.7 KB │ 7 hours ago │ 7 hours ago │ 7 hours ago 
━━━┷━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━
> ps | where cpu > 0
━━━┯━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━
 # │ pid   │ name                  │ status   │ cpu 
───┼───────┼───────────────────────┼──────────┼───────────────────
 01546 │ Xorg                  │ Sleeping │ 10.65405000000000 
 11769 │ gnome-shell           │ Sleeping │ 5.271094000000000 
 22153 │ gnome-terminal-server │ Sleeping │ 5.193664000000000 
 313556 │ nu_plugin_ps          │ Sleeping │ 40.70250000000000 
━━━┷━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━