From owner-freebsd-questions@FreeBSD.ORG Wed May 20 05:53:10 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E5ACE793 for ; Wed, 20 May 2015 05:53:10 +0000 (UTC) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B6B231183 for ; Wed, 20 May 2015 05:53:09 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 3A35D207C8 for ; Wed, 20 May 2015 01:43:47 -0400 (EDT) Received: from web2 ([10.202.2.212]) by compute3.internal (MEProxy); Wed, 20 May 2015 01:43:47 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=rubenschade.com; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=Oyq5LwiU0Hdb4XLYv0sKphnxdWc=; b=EKbaV+ C3IQ/iYPE6yxq2gWXVhpTV3mLUrPWlwfDVqr4zdlCUmyng8HkDaEpspIcrGqZwJq kELGw+8jNyx/2tf3DAvOF2p9ImRx7yrHzbdaiXmnXTRG4/l+Yho3pKNebK7sHjUd KToq2yEF5bn3RtrrHferv0N2IapTH9RyDtIbI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Oyq5LwiU0Hdb4XL Yv0sKphnxdWc=; b=YQh5UR5+1kKH8GrEh21nI5l3f0MU8fL6UG63goWcjrn8ngX x7jo8g29s0ONgQV5V5RN6efCmLn9VoqU13G1ZkiZwcvIXconLYPUf9dgSXRKwK27 VEv/WtK2mlGD19HQY+mjyLIuqJ3o/uhQKnEDyzBHPDERRWXV6Vl4npkyQZic= Received: by web2.nyi.internal (Postfix, from userid 99) id E64C3540136; Wed, 20 May 2015 01:43:46 -0400 (EDT) Message-Id: <1432100626.4010923.273434345.2D19D51B@webmail.messagingengine.com> X-Sasl-Enc: Atxqk8j45oTKPEojMRE5a4Z5tGr81g1IyOrr0zwvgLSD 1432100626 From: Ruben Schade To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-fd425702 In-Reply-To: <5559E9A4.409@FreeBSD.org> References: <20150518090051.6600f32a@seibercom.net> <5559E9A4.409@FreeBSD.org> Subject: Re: Problem with sed Date: Wed, 20 May 2015 15:43:46 +1000 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2015 05:53:11 -0000 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