From owner-freebsd-questions Thu Nov 21 18:40:50 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 9C0A937B401 for ; Thu, 21 Nov 2002 18:40:49 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1218443E88 for ; Thu, 21 Nov 2002 18:40:47 -0800 (PST) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-a064.otenet.gr [212.205.215.64]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id gAM2eciB014135; Fri, 22 Nov 2002 04:40:39 +0200 (EET) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.6/8.12.6) with ESMTP id gAM2eT7l004475; Fri, 22 Nov 2002 04:40:37 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by gothmog.gr (8.12.6/8.12.6/Submit) id gAM1THRD057762; Fri, 22 Nov 2002 03:29:17 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 22 Nov 2002 03:29:17 +0200 From: Giorgos Keramidas To: Brian Henning Cc: questions@freebsd.org Subject: Re: shell script Message-ID: <20021122012917.GD15933@gothmog.gr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On 2002-11-21 14:10, Brian Henning wrote: > 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? > #!/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; You don't really need to write the loop in shell code for printing everything up to the first ':' (which is what your shell script apparently tries to do by passing each line to awk(1). Just pass the input.txt file to awk. The following will work correctly: awk -F: '{print $1}' < input.txt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message