Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 May 2015 15:43:46 +1000
From:      Ruben Schade <newsgroups@rubenschade.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Problem with sed
Message-ID:  <1432100626.4010923.273434345.2D19D51B@webmail.messagingengine.com>
In-Reply-To: <5559E9A4.409@FreeBSD.org>
References:  <20150518090051.6600f32a@seibercom.net> <5559E9A4.409@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 18 May 2015, at 23:31, Matthew Seaman wrote:
> On 2015/05/18 14:00, Jerry wrote:
> > I rarely use sed, so I admit to not being fully acquainted with its
> > idiosyncrasies,; however, this one is really annoying.
> > 
> > I am using this command in an attempt to remove empty lines:
> > 
> > $ sed -i /^$/d /var/tmp/myfile.txt
> > 
> > and get this error:
> > 
> > sed: 1: "/var/tmp/myfile.txt": undefined label 'mp/myfile.txt'
> > 
> > I don't understand why. I am following the example I found in the "sed & awk" handbook by "O'Reilly"
> > 
> 
> sed -i.bak -e '/^$/d' /var/tmp/myfile.txt
> 
> You're getting sed(1) confused as to what is the extension for the
> backup of the file it creates, what the command you want to rn is and
> what the input filename is.  Also, you need to put some characters of
> syntactic significance to the shell inside quote marks.
> 
> 	Cheers,
> 
> 	Matthew
> 
> 
> Email had 1 attachment:
> + signature.asc
>   1k (application/pgp-signature)

Part the confusion may lie in the difference between GNU and BSD
userland sed, which I'll admit has bitten me a few times.

GNU sed will accept -i (without an argument) as in-line edit to the
original file. For BSD sed, you need an empty string (-i '').

-- 
Cheers,
Ruben Schade 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1432100626.4010923.273434345.2D19D51B>