]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/redact
fstype: make copy of first sector in /env to avoid unaligned reads on the disk (for...
[plan9front.git] / rc / bin / redact
1 #!/bin/rc
2 rfork e
3 switch($#*){
4 case 0
5         n=1
6 case 1
7         n = $1
8 case *
9         echo usage: $0 [n] >[1=2]
10         exit usage
11 }
12 ifs='
13 '
14 p=`{echo -n $prompt(1) | sed 's/[.*+?[\]()|\^$\/\\]/\\&/g'}
15 awk '
16         BEGIN {
17                 n='^$n^' + 1;
18                 for(i = 0; i < n; i++)
19                         a[i] = 0;
20         }
21         /^'^$p^'/ {
22                 for(i = 0; i < n-1; i++)
23                         a[i] = a[i+1];
24                 a[n-1] = 0;
25         }
26         {
27                 a[n-1] += length($0) + 1;
28         }
29         END {
30                 s = 0;
31                 for(i = 0; i < n; i++)
32                         s += a[i];
33                 for(i = 0; i < s; i++)
34                         printf("\b");
35         }
36 ' /dev/text