From owner-freebsd-questions@FreeBSD.ORG Wed Feb 20 12:46:41 2013 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 847A8F34 for ; Wed, 20 Feb 2013 12:46:41 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id 4E4B0F4D for ; Wed, 20 Feb 2013 12:46:41 +0000 (UTC) Received: from r56.edvax.de (port-92-195-74-250.dynamic.qsc.de [92.195.74.250]) by mx02.qsc.de (Postfix) with ESMTP id 1552B24826; Wed, 20 Feb 2013 13:46:33 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r1KCkbHo009109; Wed, 20 Feb 2013 13:46:38 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Wed, 20 Feb 2013 13:46:37 +0100 From: Polytropon To: Fbsd8 Subject: Re: sh script & files Message-Id: <20130220134637.58d8a913.freebsd@edvax.de> In-Reply-To: <5124C428.1080909@a1poweruser.com> References: <5124C428.1080909@a1poweruser.com> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 12:46:41 -0000 On Wed, 20 Feb 2013 07:40:08 -0500, Fbsd8 wrote: > # write to file > > "${file}" > > I'm thinking the file is never closed so on power failure I loose the > contents of the file. > > How would I code a command to close the file? The file is closed when the write operation has been finished. You can use the "sync" command to flush pending writes to the file (as writing is handled asynchronously by the system). When the program that writes to the file exits, it will close the file it's writing to. This depends on the command you're using infront of >, as the command you've shown will simply generate a null file (file with no actual content). -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...