Subject: Re: bug#20572: bug about sed when use -i

From: Lu Qin <[email-masked]>
Date: Fri, 15 May 2015 09:54:13 +0800

Thank you for you replay.

I google the problem and I found that It is because I use mac and the sed version is not same as the GNU sed .

> 在 2015年5月15日，06:39，Norihiro Tanaka <[email-masked]> 写道：
> 
> 
> On Thu, 14 May 2015 17:00:58 +0800
> Lu Qin <[email-masked]> wrote:
> 
>> when I use sed like this :
>> 
>> sed -i  -e 's/\(public class TInfo .*\)$/\1\
>> \
>>  private static final long serialVersionUID = -4659975753252858243l; \/\/ See ACCUMULO-3132\
>> /' src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
>> 
>> It will create a file name TInfo.java-e as a backup,but the -e is not the backup extension I use.
>> 
>> 
>> If I use it like this:
>> sed -i ''  -e 's/\(public class TInfo .*\)$/\1\
>> \
>>  private static final long serialVersionUID = -4659975753252858243l; \/\/ See ACCUMULO-3132\
>> /' src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
>> 
>> It will be work ok and not create a backup file what I want.
> 
> $ tar xzf accumulo-1.6.2-src.tar.gz
> $ cd accumulo-1.6.2/trace
> 
> $ sed --version
> sed (GNU sed) 4.2.2
> Copyright (C) 2012 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> 
> Written by Jay Fenlason, Tom Lord, Ken Pizzini,
> and Paolo Bonzini.
> GNU sed home page: <http://www.gnu.org/software/sed/>.
> General help using GNU software: <http://www.gnu.org/gethelp/>.
> E-mail bug reports to: <[email-masked]>.
> Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
> 
> $ sed -i -e 's/\(public class TInfo .*\)$/\1\
> \
>  private static final long serialVersionUID = -4659975753252858243l; \/\/ See ACCUMULO-3132\
> /' src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
> 
> $ ls src/main/java/org/apache/accumulo/trace/thrift/TInfo.java*
> src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
> 
> $ sed -i ''  -e 's/\(public class TInfo .*\)$/\1\
> \
>  private static final long serialVersionUID = -4659975753252858243l; \/\/ See ACCUMULO-3132\
> /' src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
> sed: can't read : No such file or directory
> 
> $ ls src/main/java/org/apache/accumulo/trace/thrift/TInfo.java*
> src/main/java/org/apache/accumulo/trace/thrift/TInfo.java
> 
> 
> I see that it is not a bug.
> 
>