Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there a way to make sed ask me for confirmation before each replace? Something similar to 'c' when using replace inside vim.

Does sed do this at all?

share|improve this question
It would be technically possible but more of an intellectual exercise than a useful endeavor. See How to do a text replacement in a big folder hierarchy? which has Vim and Perl solutions. –  Gilles Sep 6 '11 at 0:20
I am using vim (args and argdo) whenever I need 'confirmation', but was wondering if there was a 'simpler' way –  Yuvi Sep 7 '11 at 19:26

2 Answers 2

Doing it with sed would probably be possible but would require far too much thinking. It is easier to just do it with vim:

vim -c '%s/PATTERN/REPLACEMENT/gc' -c 'wq' file.in
share|improve this answer

You can get this by doing such:


Specifically, adding the c after the third delimiter.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.