| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | #================================================================ |
| 4 | # edswap |
| 5 | # Swap strings with ed command |
| 6 | #================================================================ |
| 7 | |
| 8 | |
| 9 | # check arguments |
| 10 | if [scip-shell system . . `[`. $# -lt 3 ] |
| 11 | then |
| 12 | printfscip-shell system . . printf. 'edswap: usage: edswap regex string files...\n' 1>&2 |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | |
| 17 | # make expressions |
| 18 | bef=`printfscip-shell system . . printf. "$1" | sedscip-shell system . . sed. 's/\//\\\\\//g'` ; shift |
| 19 | aft=$1 ; shift |
| 20 | |
| 21 | |
| 22 | # edit files |
| 23 | while [scip-shell system . . `[`. -n "$1" ] |
| 24 | do |
| 25 | printfscip-shell system . . printf. "== $1 ==\n" |
| 26 | printfscip-shell system . . printf. "1,\$ s/$bef/$aft/g\nw\n" | edscip-shell system . . ed. "$1" |
| 27 | shift |
| 28 | done |
| 29 | |
| 30 | |
| 31 | # exit normally |
| 32 | exit 0 |
| 33 | |
| 34 | |
| 35 | |
| 36 | # END OF FILE |