From owner-freebsd-questions Thu Nov 21 13:51: 7 2002 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 4F9C737B401 for ; Thu, 21 Nov 2002 13:51:05 -0800 (PST) Received: from mail.pinboard.com (mail.pinboard.com [194.209.195.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7ADCA43E6E for ; Thu, 21 Nov 2002 13:51:03 -0800 (PST) (envelope-from kurt@pinboard.com) Received: (from uucp@localhost) by mail.pinboard.com (8.11.6/8.9.3/20011223-00-KK) with UUCP id gALLorF73680; Thu, 21 Nov 2002 22:50:53 +0100 (CET) (envelope-from kurt@pinboard.com (kurt@pinboard.com)) (client-IP ) Received: (from kurt@localhost) by badger.pbdhome.pinboard.com (8.9.3/8.9.3/20011223-00-KK) id WAA22826; Thu, 21 Nov 2002 22:49:17 +0100 (CET) (envelope-from kurt (kurt)) (client-IP ) Date: Thu, 21 Nov 2002 22:49:16 +0100 From: pbdlists@pinboard.com To: Brian Henning Cc: questions@FreeBSD.ORG Subject: Re: shell script Message-ID: <20021121224915.B21940@pinboard.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from b1henning@hotmail.com on Thu, Nov 21, 2002 at 02:10:48PM -0600 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hello Brian, First of all, your script will not run, you forgot a closing quote on the third line from the end. But not to your problem. I was pounding over a similar issue recently and the solution I came up with was to replace the for loop with a while loop combined with a read command. not working: for L in `cat inputfile` do echo "the line read is: ${L}" done works fine: cat inputfile | while read L do echo "the line read is: ${L}" done Cheers, Kurt On Thu, Nov 21, 2002 at 02:10:48PM -0600, Brian Henning wrote: > Hello, > > i have a simple shell script problem. if i have a file name with a space in > the name the following script doesn't get the entire name. The for loop > conditional statement below stops for spaces or new lines... i would like it > to stop for just new lines. is there a way to do that with shell script. how > can i change the condition in the for loop to do that? > > Thanks, > brian > > input.txt > -------- > Tom Petty - Free Fallin'.mp3 > Dave Matthews.mp3 > > > size.sh > ------- > #!/bin/sh -x > # sh size.sh /smb/dc input.txt > > PATH=$1 > INPUT=$2 > > for i in `/bin/cat ${INPUT}`; do > echo "in loop" > FILE=`echo $i | /usr/bin/awk -F: '{ print $1 }'` > SIZE=`echo $i | /usr/bin/awk -F: '{ print $2 }'` > > echo "${FILE} > done > exit 0; > > > current result > ------------- > Tom > Petty > - > Free > Fallin'.mp3 > Dave > Matthews.mp3 > > > desired result > -------------- > Tom Petty - Free Fallin'.mp3 > Dave Matthews.mp3 -- ---------------------------------------------------------------------- : Kurt@pinboard.com http://www.pinboard.com/ business : : http://kurt.www.pinboard.com/ private : ---------------------------------------------------------------------- : Unix and Internet Specialist : : PGP fingerprint C34E BCD4 BA8B 1337 14FE 116C 2657 FFAC 08B9 BFC7 : ---------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message