Subject: Re: [quicwg/base-drafts] My sed-fu is lacking (dc887e8)

From: MikkelFJ <[email-masked]>
Date: Thu, 08 Mar 2018 01:42:20 -0800

function ag-replace --description "replace-global <search> <replace> [<file-pattern>]"
    # backs up changed files in *.bak
    if set -q $argv[3]
        ag -l $argv[1] $argv[3] | xargs sed -i -e "s/$argv[1]/$argv[2]/g"
    else
        ag -l $argv[1] | xargs sed -i -e "s/$argv[1]/$argv[2]/g"
    end
end

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/commit/dc887e85a50ece81bfbb87c44dfaf27d91c42f28#commitcomment-27992409

---

From: Dmitri Tikhonov <[email-masked]>
Date: Thu, 08 Mar 2018 14:02:35 +0000 (UTC)

What shell is this?

Why not simply `perl -pi s/old/new/ some/files*` ?

See `perlrun(1)`

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/commit/dc887e85a50ece81bfbb87c44dfaf27d91c42f28#commitcomment-27996540

---

From: MikkelFJ <[email-masked]>
Date: Thu, 08 Mar 2018 14:18:50 +0000 (UTC)

it's a fish shell - but it was more to name the args.
I just run `ag-replace from to`
ag (silversearcher) is fast, recursive, and I don't need to remember stuff I only use every second moon.
Also great as a replacement for `find`, which I have given up on understanding.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/commit/dc887e85a50ece81bfbb87c44dfaf27d91c42f28#commitcomment-27996762

---

From: MikkelFJ <[email-masked]>
Date: Thu, 08 Mar 2018 14:34:38 +0000 (UTC)

For completion, here is the function to clean up the backup files after replace
```
function ag-clean
    rm -R **-e
end
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/commit/dc887e85a50ece81bfbb87c44dfaf27d91c42f28#commitcomment-27996971