From owner-freebsd-questions@FreeBSD.ORG Thu May 18 08:27:23 2006 Return-Path: X-Original-To: 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 D074816A40A for ; Thu, 18 May 2006 08:27:23 +0000 (UTC) (envelope-from kyrreny@broadpark.no) Received: from osl1smout1.broadpark.no (osl1smout1.broadpark.no [80.202.4.58]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2BC0443D49 for ; Thu, 18 May 2006 08:27:23 +0000 (GMT) (envelope-from kyrreny@broadpark.no) Received: from osl1sminn1.broadpark.no ([80.202.4.59]) by osl1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG004URCTM18A0@osl1smout1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 10:27:22 +0200 (CEST) Received: from urban.broadpark.no ([80.203.212.30]) by osl1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0IZG00DAHCTLBUF0@osl1sminn1.broadpark.no> for questions@freebsd.org; Thu, 18 May 2006 10:27:21 +0200 (CEST) Date: Thu, 18 May 2006 10:27:22 +0200 From: Kyrre Nygard In-reply-to: To: Atom Powers Message-id: <7.0.1.0.2.20060518102146.021fa540@broadpark.no> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT References: <7.0.1.0.2.20060516105228.02238068@broadpark.no> Cc: questions@freebsd.org Subject: Re: Some shell scripts; a more elegant approach? 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: Thu, 18 May 2006 08:27:23 -0000 At 17:59 16.05.2006, Atom Powers wrote: >It is difficult to understand exactly what you want your script to do >without comments. You may get a better response if you can describe >what you want your scripts to do. Thanks man, your advice was really helpful! This though: -- for file in `find -s . -type f -name "*.txt"`; do # This removes CRLF, double or more empty lines # as well as trailing whitespace. # tr -d '\r' < $file | cat -s | sed -E -e 's/[[:space:]]+$//' > $file.tmp # Creates file blank containing an empty line # echo > blank # Add an empty line to the end of $file.tmp # echo >> $file.tmp # $file now starts with an empty line too # cat blank $file.tmp >> $file rm -f blank $file.tmp done for file in `find . -type f -name "*.txt" -size -300c`; do echo "$file: Corrupt" done -- I'd like to incorporate the 2nd for loop into the first somehow. That last find command finds files that are below 300 bytes. Now I'm sure there's a better way of doing that. Thanks Atom Powers! :) Take care, Kyrre