# read-nth-line

> Get the nth line from a file using sed.

Latest version **2.0.0** (published 2024-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install read-nth-line
pnpm add read-nth-line
yarn add read-nth-line
bun add read-nth-line
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-02-17 |
| First published | 2018-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | mistval |
| Maintainers | rschmidt |
| Keywords | nth, line, from, file, read, xth, sed, readline |

## Links

- npm: https://www.npmjs.com/package/read-nth-line
- Repository: https://github.com/mistval/nth-line
- Homepage: https://github.com/mistval/nth-line#readme
- Issues: https://github.com/mistval/monochrome/issues
- npm.io page: https://npm.io/package/read-nth-line

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-02-17
- 1.0.3 — 2019-01-19
- 1.0.2 — 2018-02-28
- 1.0.1 — 2018-02-28
- 1.0.0 — 2018-01-27

## README

# read-nth-line

Read the nth line of a file with sed. Your system must have sed available. For large files, this is more efficient than using readline. However, due to the overhead of spawning a shell process, readline is more efficient for smaller files.

## Usage

**Asynchronous**

```js
const nthLine = require('read-nth-line');

nthLine.read(__dirname + '/notes.txt', 150).then(result => {
  console.log(result);
}).catch(err => {
  console.warn(err);
});
```

**Synchronous**

```js
const nthLine = require('read-nth-line');

try {
  console.log(nthLine.readSync(__dirname + '/notes.txt', 150));
} catch (err) {
  console.warn(err);
}
```

The first line in your file is line 0, and if you don't pass in an absolute path, the file path is relative to the directory that node is executing in. Consider using __dirname to fully qualify the file path.

---
_Source: https://npm.io/package/read-nth-line · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
