I apply sed 's/^ bug*/__/'
to
ref bug
bug ref
and get
ref __
__ ref
The same is responded for perl, perl -ni -e 's/^ bug/__/; print'
. Sample file can be downloaded from here. Sed and perl are cygwin utilities that I run from the Windows command line. When I run them through cygwin bash, this stuff does not happen.
Answer
The problem has to do with cmd.exe's "quirks" (for lack of a better word) with handling non-alphanumeric characters within single quotes in this case. Essentially, the caret and space characters are being ignored.
The easiest way to avoid the problem (if running it in a proper Cygwin bash shell is not a desirable option) would be to use double quotes instead...
C:\cygwin\home\costa\wk>sed 's/^ bug*/__/' sed.txt
ref __
__ ref
C:\cygwin\home\costa\wk>sed "s/^ bug*/__/" sed.txt
ref bug
__ ref
No comments:
Post a Comment