Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site luke.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!drutx!mtuxo!mtunh!mtung!mtunf!ariel!vax135!cornell!uw-beaver!tektronix!hplabs!oliveb!bene!luke!sml From: sml@luke.UUCP (Steven List) Newsgroups: net.unix-wizards Subject: Re: Adding up columns of numbers... Message-ID: <237@luke.UUCP> Date: Tue, 18-Jun-85 14:48:33 EDT Article-I.D.: luke.237 Posted: Tue Jun 18 14:48:33 1985 Date-Received: Mon, 24-Jun-85 03:00:30 EDT References: <975@trwatf.UUCP> <992@trwatf.UUCP> Reply-To: steven@luke.UUCP (Steven List) Organization: Uncle Bene's Farm Lines: 30 Keywords: awk field separators In article <992@trwatf.UUCP> root@trwatf.UUCP (Lord Frith) writes: >Something I have noticed that disturbs me is why awk seems to think >that there is an object between field seperators when that object is >null. In other words; awk will process three consecutive tabs and say >that there are two fields whose values are null. Remember that they are indeed `field separators'! Why should awk NOT treat two consecutive separators as containing an empty field? This is a perfectly legitimate use. There are times when a field is empty, and you wouldn't want awk to treat field 3 as field 2, would you? Take the following example, in which the third and fourth fields are address lines: Smith|John|1234 Jones Street||San Francisco|CA|94111 Brown|Jack MD|Suite 234|2345 Smith Street|San Francisco|CA|94111 Clearly, it is desirable in the first case to treat the empty field as a field in order not to process the city as an address line (and so on). Remember, again, that field separators are field separators, not white space. Sort has the same problem/feature. Any others? If this continues to be a problem, use something like sed to distill the file: sed 's/[ \t][ \t]*/ /g' | awk ... Then you won't have the problem/feature to contend with. Of course, you might run into OTHER problems. Another option is to use the `substr' builtin function if you have fixed format files.