diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-08-25 11:11:15 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-08-25 11:11:15 +0100 |
commit | dabf9cc14f37a97b46ef08228d77ee7c3916dad0 (patch) | |
tree | 19f7cfa2227af0c9f90255403c2d6a28e03845f4 | |
parent | 1ae9ddb9a65b8a7277e8a230a57f298503ef23bc (diff) | |
download | obnam-dabf9cc14f37a97b46ef08228d77ee7c3916dad0.tar.gz |
Add GNU sed -i emulation script
-rwxr-xr-x | sed-in-place | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sed-in-place b/sed-in-place new file mode 100755 index 00000000..13e6258b --- /dev/null +++ b/sed-in-place @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Do a sed in place for a set of files. This is like GNU sed -i, but +# we can't assume GNU sed. + +set -eu + +sedcmd="$1" +shift + +for filename in "$@" +do + temp="$(mktemp)" + sed "$sedcmd" "$filename" > "$temp" + mv "$temp" "$filename" +done
\ No newline at end of file |