Sign up ×
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
It goes against the basic purpose of sed - to automate editing over a stream. – teppic Oct 1 at 17:24

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'
share|improve this answer

You can get this by doing such:


Specifically, adding the c after the third delimiter.

Note that the 'c' option only works in Vim; you won't be able to use it with sed at the command line.

share|improve this answer
To clarify: this only works in Vim, not regular command line sed. – Brendan Oct 1 at 15:28

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.