From owner-freebsd-questions@FreeBSD.ORG Thu Mar 30 15:20:35 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 C0E6716A425 for ; Thu, 30 Mar 2006 15:20:35 +0000 (UTC) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (clunix.cl.msu.edu [35.9.2.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7CF4743D68 for ; Thu, 30 Mar 2006 15:20:33 +0000 (GMT) (envelope-from jerrymc@clunix.cl.msu.edu) Received: from clunix.cl.msu.edu (localhost [127.0.0.1]) by clunix.cl.msu.edu (8.13.6+Sun/8.12.2) with ESMTP id k2UFKVgs005941; Thu, 30 Mar 2006 10:20:31 -0500 (EST) Received: (from jerrymc@localhost) by clunix.cl.msu.edu (8.13.6+Sun/8.12.2/Submit) id k2UFKVCO005940; Thu, 30 Mar 2006 10:20:31 -0500 (EST) From: Jerry McAllister Message-Id: <200603301520.k2UFKVCO005940@clunix.cl.msu.edu> To: vaaf@broadpark.no (Vaaf) Date: Thu, 30 Mar 2006 10:20:31 -0500 (EST) In-Reply-To: <7.0.1.0.2.20060330165636.020cc010@broadpark.no> X-Mailer: ELM [version 2.5 PL7] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: questions@freebsd.org Subject: Re: ASCII files becoming double lined 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, 30 Mar 2006 15:20:35 -0000 > > > Hello! > > Sometimes I notice ASCII files becoming double lined. > As in there somehow appearing an empty line in between every line. > > Why is this? And: > > 01 How can I detect files with double lines? > 02 And then eliminate this double lining? Check out tr(1) It will quite easily remove the extra CR in every line. Then, if you need, you can rename the clean file to the dirty file something like: # tr -d "\r" < dirtyfile > cleanfile # mv cleanfile dirtyfile Sorry, it takes two steps. Thre are other methods that do it without a second file, but for newbies, this is easier to understand. ////jerry > > The goal would be to apply 01 and 02 to this script: > > #!/usr/local/bin/bash > # > # Remove CRLF, trailing whitespace and blank lines. > # $MARBEJA: clean.sh,v 1.0 2007/11/11 15:09:05 awad Exp $ > # > > for file in `find -s . -type f`; do > > if file -b "$file" | grep -q 'text'; then > > echo >> "$file" > > tr -d '\r' < "$file" \ > | sed -E -e 's/[[:space:]]+$//' \ > | cat -s - > "${file}.tmp" && mv -f "${file}.tmp" "$file" > > echo "$file: Done" > > fi > > done > > Thanks, > Vaaf > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >