From owner-freebsd-questions Wed Jan 19 22: 8:31 2000 Delivered-To: freebsd-questions@freebsd.org Received: from unknown-230-100.pilot.net (unknown-230-100.pilot.net [206.98.230.100]) by hub.freebsd.org (Postfix) with ESMTP id 9F662152CE for ; Wed, 19 Jan 2000 22:08:29 -0800 (PST) (envelope-from sivaramn@wipsys.ge.com) Received: from unknown-239-164.pilot.net (unknown-239-164.pilot.net [206.189.239.164]) by unknown-230-100.pilot.net with ESMTP id BAA11920 for ; Thu, 20 Jan 2000 01:08:29 -0500 (EST) Received: from gemail.wipsys.ge.com (localhost [127.0.0.1]) by unknown-239-164.pilot.net with ESMTP id BAA17323 for ; Thu, 20 Jan 2000 01:08:24 -0500 (EST) Received: from Sivaram ([192.168.47.139]) by gemail.wipsys.ge.com (Netscape Messaging Server 3.6) with SMTP id AAA408D for ; Thu, 20 Jan 2000 11:43:36 +0530 Message-ID: <00e501bf6307$5cd13a80$8b2fa8c0@wipsys.ge.com> Reply-To: "Sivaram Neelakantan" From: "SIVARAM N" To: Date: Thu, 20 Jan 2000 10:59:45 +0530 Organization: wipro MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, I hope this is the right list to ask... I have 2 questions actually. 1. I have a comma separated records in a file where most fields have leading whitespaces. Setting FS="," & reading the file preserves the leading whitespaces. how do I remove them? I have gawk installed & there's this match() operator where it sets the RSTART & RLENGTH parameter. Now , I'm not getting the code right which looks for spaces at the beginning of the field . Why doesn't this work BEGIN {spc="^[ ][ ]*"} ... if($2 ~spc ){ pos=match($2,spc) .... 2. How can you find out whether the end of file has been reached for a specific file given multiple files? I have 2 files , the first needs to be read into an associative array in BEGIN before I work with the second file in the body of the program . How do I check for end of file in BEGIN? One suggestion I got was to mark the last line of the first file with a marker like NEXTFILE BEGIN { FS=","; state="preload"; I=1} { if($0~/^NEXTFILE/) { state="loaded2"; next } if(state == "preload") ... else { ... Supposing I dont want to touch the files?? Regards, Sivaram To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message