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

https://github.com/nightmachinery/rmprefix

rmprefix can 1) remove a given prefix from the lines of input 2) replace a literal string with another.
https://github.com/nightmachinery/rmprefix

awk prefix sd sed string string-manipulation string-matching

Last synced: 3 months ago
JSON representation

rmprefix can 1) remove a given prefix from the lines of input 2) replace a literal string with another.

Awesome Lists containing this project

README

          

# DEPRECATED

Use https://github.com/NightMachinary/prefixer instead. I'll continue to support bugfixes for `rmprefix`, as it's a very lightweight command and I still use it in my scripts, but `prefixer` is better in virtually every way.

# Installation

```
cargo install --git https://github.com/NightMachinary/rmprefix --force
```

# Usage

`rmprefix` removes the given prefix from its input if present. The input is split using the given separator, by default newlines.

Usage: `rmprefix [=\n] [=\n]`

Set the separators to `\x00` for the NUL character.

`rmprefix` can also work as a search and replace tool, with this neat trick:

`rmprefix '' SEARCH_FOR_ME REPLACE_WITH_ME`

## Examples

```
echo "The jungles are green.
Some people sing.
The world is not flat.
There are two ways." | rmprefix The
```

> jungles are green.
>
>Some people sing.
>
> world is not flat.
>
>re are two ways.

```
echo "123456789" "23456789" "12345" "Hi" "" "Ocean" | rmprefix 123 ' ' '|||'
```

> 456789|||23456789|||45|||Hi||||||Ocean

```
echo "Butterflies are insects in the macrolepidopteran clade Rhopalocera from the order Lepidoptera, which also includes moths. Adult butterflies have large, often brightly coloured wings, and conspicuous, fluttering flight. The group comprises the large superfamily Papilionoidea, which contains at least one former group, the skippers (formerly the superfamily "Hesperioidea"), and the most recent analyses suggest it also contains the moth-butterflies (formerly the superfamily "Hedyloidea"). Butterfly fossils date to the Paleocene, about 56 million years ago." | rmprefix '' butter cheese
```

> Butterflies are insects in the macrolepidopteran clade Rhopalocera from the order Lepidoptera, which also includes moths. Adult cheeseflies have large, often brightly coloured wings, and conspicuous, fluttering flight. The group comprises the large superfamily Papilionoidea, which contains at least one former group, the skippers (formerly the superfamily Hesperioidea), and the most recent analyses suggest it also contains the moth-cheeseflies (formerly the superfamily Hedyloidea). Butterfly fossils date to the Paleocene, about 56 million years ago.

# Licenses

Dual-licensed under MIT and GPL v3 or later.