An open API service indexing awesome lists of open source software.

https://github.com/hugojosefson/sponge

Reimplementation of sponge from moreutils, for Deno.
https://github.com/hugojosefson/sponge

deno moreutils sponge typescript

Last synced: 13 days ago
JSON representation

Reimplementation of sponge from moreutils, for Deno.

Awesome Lists containing this project

README

          

# sponge

Reimplementation of `sponge(1)` from
[moreutils](https://joeyh.name/code/moreutils/), for Deno.

[![JSR](https://jsr.io/badges/@moreutils/sponge)](https://jsr.io/@moreutils/sponge)
[![CI](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml/badge.svg)](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml)

## Requirements

Requires [Deno](https://deno.land/) v1.44.1 or later.

## Usage

### Soak up stdin, write to stdout

```sh
deno run jsr:@moreutils/sponge
```

### Soak up stdin, write to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
```

### Soak up stdin, append to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge -a file.txt
```

## Example usage

Given a file `file.txt` with the following contents:

```
The quick brown fox jumps over the lazy dog.

The foo bar baz.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

Running this command, will replace its contents with the same, piped through
`sed`:

```sh
cat file.txt |
sed -e 's/foo/bar/' |
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
```