cygwin sed substitution against commands in history

Posted by Ira on Stack Overflow See other posts from Stack Overflow or by Ira
Published on 2010-06-15T20:08:56Z Indexed on 2010/06/15 20:12 UTC
Read the original article Hit count: 209

Filed under:
|
|
|

I couldn't find an answer for this exact problem, so I'll ask it.

I'm working in Cygwin and want to reference previous commands using !n notation, e.g., if command 5 was which ls, then !5 runs the same command.

The problem is when trying to do substitution, so running:

!5:s/which \([a-z]\)/\1/

should just run ls, or whatever the argument was for which for command number 5.

I've tried several ways of doing this kind of substitution and get the same error:

bash: :s/which \([a-z]*\)/\1/: substitution failed

© Stack Overflow or respective owner

Related posts about sed

Related posts about cygwin