From 19bd70185de78f86f062d30beb299fcdb474c3ec Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 22 Apr 2017 01:59:04 -0400 Subject: [PATCH] bin/replace: refactor --- bin/replace | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/replace b/bin/replace index 8c2a906d..5c1b8de7 100755 --- a/bin/replace +++ b/bin/replace @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # Find and replace by a given list of files. # @@ -8,7 +8,6 @@ find_this="$1"; shift replace_with="$1"; shift items=( $(ag -l --nocolor "$find_this" "$@") ) -temp="${TMPDIR:-/tmp}/replace_tmp.$$" for item in ${items[@]}; do - sed "s/$find_this/$replace_with/g" "$item" > "$temp" && mv "$temp" "$item" + sed -i "s/${find_this}/${replace_with}/g" "$item" done