From owner-freebsd-questions@FreeBSD.ORG Tue Oct 23 19:45:31 2007 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C4B916A46B for ; Tue, 23 Oct 2007 19:45:31 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.freebsd.org (Postfix) with ESMTP id 979FE13C4B7 for ; Tue, 23 Oct 2007 19:45:30 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.1/8.14.1) with ESMTP id l9NJhFH4051945; Tue, 23 Oct 2007 21:43:22 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.1/8.14.1/Submit) id l9NJhF8T051944; Tue, 23 Oct 2007 21:43:15 +0200 (CEST) (envelope-from olli) Date: Tue, 23 Oct 2007 21:43:15 +0200 (CEST) Message-Id: <200710231943.l9NJhF8T051944@lurza.secnetix.de> From: Oliver Fromme To: freebsd-questions@FreeBSD.ORG, dnelson@allantgroup.com In-Reply-To: <20071023163135.GA74788@dan.emsphone.com> X-Newsgroups: list.freebsd-questions User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.2-STABLE-20070808 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Tue, 23 Oct 2007 21:43:24 +0200 (CEST) Cc: Subject: Re: oflag option in GNU dd - equivalent in FreeBSD dd ? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-questions@FreeBSD.ORG, dnelson@allantgroup.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2007 19:45:31 -0000 Dan Nelson wrote: > Oliver Fromme wrote: > > Of course, the easiest way is to do this: > > > > $ dd if=/blah >> /bleh I still think the OP should prefer that solution. > > If you cannot do that, please explain why. If you know > > your reason, there might be an alternative way to do it. > > > > > dd if=/blah of=/bleh conv=notrunc seek=`ls -s /bleh | cut -f1 -d ' ' -` > > > > > > I don't know if any simpler way is possible (anyone?). > > > > $ dd if=/blah of=/bleh conv=notrunc seek=$(stat -f%z /bleh) > > I don't think that will work, since seek's argument is in blocks. Oops, you're right. I forgot about that. > Even > if you divide by 512 (or whatever you decide to set bs=), if the file > you're appending do isn't a multiple of the blocksize, you'll end up > chopping part of the end off. I wonder how GNU dd's "append" oflag behaves in that case. It would also either have to chop some bytes off the end, or leave a gap of zeros. Either way could be emulated. $ dd if=/blah of=/bleh conv=notrunc seek=$(( $(stat -f%z /bleh) / 512 )) That one would chop some bytes of the end if the file size isn't a multiple of 512 (the default block size). To leave a gap in that case, use this formula: $ ... seek=$(( ($(stat -f%z /bleh) + 511) / 512 )) Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "Emacs ist für mich kein Editor. Für mich ist das genau das gleiche, als wenn ich nach einem Fahrrad (für die Sonntagbrötchen) frage und einen pangalaktischen Raumkreuzer mit 10 km Gesamtlänge bekomme. Ich weiß nicht, was ich damit soll." -- Frank Klemm, de.comp.os.unix.discussion