From owner-freebsd-questions@FreeBSD.ORG Mon Oct 30 15:31:04 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7E28D16A417 for ; Mon, 30 Oct 2006 15:31:04 +0000 (UTC) (envelope-from user@dhp.com) Received: from shell.dhp.com (shell.dhp.com [199.4.150.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6481043D46 for ; Mon, 30 Oct 2006 15:31:04 +0000 (GMT) (envelope-from user@dhp.com) Received: by shell.dhp.com (Postfix, from userid 896) id 42AFE263F6; Mon, 30 Oct 2006 10:30:57 -0500 (EST) Date: Mon, 30 Oct 2006 10:30:57 -0500 (EST) From: Ensel Sharon To: freebsd-questions@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: file redirect is destroying the file ? Help! X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Oct 2006 15:31:04 -0000 I have a script that, among other things, removes a line from /etc/ftpchroot. I do this with this method: cat /etc/ftpchroot | grep -v $remove > /etc/ftpchroot Easy. You cat all of the file except the line you want to remove, and redirect it back to itself. The problem is, about 50% of the time, I end up with an empty ftpchroot file. It is zero bytes. This obviously has nothing to do with a bad variable, since if it wasn't there, the starting file and ending file would just be identical. Instead, I get an empty file. I have reproduced this with other files in other places - works some of the time, other times gives me an empty file. What gives ? (note, I know a lot of ways to work around this - so I'm not so much asking how to fix this, as I am asking "why does this happen" ?)