shithub: rc

Download patch

ref: 93b4ead82df905b4485e65470acb9a7b41c34f89
parent: 45617648bc7179ec433ad4c808b0ab93246849ed
author: qwx <qwx@sciops.net>
date: Sun Jan 30 13:35:53 EST 2022

add r: like redact(1) but clear a single numbered command's output in buffer

--- /dev/null
+++ b/bin/r
@@ -1,0 +1,12 @@
+#!/bin/rc
+rfork e
+x=1
+if(! ~ $#* 0)
+	x=$1
+awk -v 'x='^$x '
+/^; /{
+	a[++n] = NR
+} END {
+	cmd = a[n-x]","a[n-x+1]-1"d;"NR"d"
+	system("sed \''" cmd "\'' /dev/text >/tmp/a; mv /tmp/a /dev/text")
+}' /dev/text