nushell/docs/commands/lines.md
Waldir Pimenta 5ca9e12b7f
Fix whitespace and typos (#1481)
* Remove EOL whitespace in files other than docs

* Break paragraphs into lines

See http://rhodesmill.org/brandon/2012/one-sentence-per-line/ for the rationale

* Fix various typos

* Remove EOL whitespace in docs/commands/*.md
2020-03-14 06:23:41 +13:00

972 B

lines

This command takes a string from a pipeline as input, and returns a table where each line of the input string is a row in the table. Empty lines are ignored. This command is capable of feeding other commands, such as nth, with its output.

Usage

> [input-command] | lines

Examples

Basic usage:

> printf "Hello\nWorld!\nLove, nushell." | lines
━━━┯━━━━━━━━━━━━━━━━
 # │ value
───┼────────────────
 0 │ Hello
 1 │ World!
 2 │ Love, nushell.
━━━┷━━━━━━━━━━━━━━━━

One useful application is piping the contents of file into lines. This example extracts a certain line from a given file.

> cat lines.md | lines | nth 6
## Examples

Similarly to this example, lines can be used to extract certain portions of or apply transformations to data returned by any program which returns a string.