1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#!/bin/bash # Simple multi-line search and replace # # mrep [-i] FILE "pattern" # Where pattern is a the part between s/.../msg in perl opts= file= if [ "$1" == "-i" ]; then opts=-i file=$2 shift 2 fi perl $opts -e " undef \$/; # each read is whole file while (<>) { # get one whole file at a time s/$1/msg; print; # print file to STDOUT } " $file |