add redact(1)
This commit is contained in:
parent
58b6cdfdeb
commit
e5de0d457a
1 changed files with 36 additions and 0 deletions
36
rc/bin/redact
Executable file
36
rc/bin/redact
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/rc
|
||||
rfork e
|
||||
switch($#*){
|
||||
case 0
|
||||
n=1
|
||||
case 1
|
||||
n = $1
|
||||
case *
|
||||
echo usage: $0 [n] >[1=2]
|
||||
exit usage
|
||||
}
|
||||
ifs='
|
||||
'
|
||||
p=`{echo -n $prompt(1) | sed 's/[.*+?[\]()|\^$\/\\]/\\&/g'}
|
||||
awk '
|
||||
BEGIN {
|
||||
n='^$n^' + 1;
|
||||
for(i = 0; i < n; i++)
|
||||
a[i] = 0;
|
||||
}
|
||||
/^'^$p^'/ {
|
||||
for(i = 0; i < n-1; i++)
|
||||
a[i] = a[i+1];
|
||||
a[n-1] = 0;
|
||||
}
|
||||
{
|
||||
a[n-1] += length($0) + 1;
|
||||
}
|
||||
END {
|
||||
s = 0;
|
||||
for(i = 0; i < n; i++)
|
||||
s += a[i];
|
||||
for(i = 0; i < s; i++)
|
||||
printf("\b");
|
||||
}
|
||||
' /dev/text
|
Loading…
Reference in a new issue