home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.lang.awk
- Path: sparky!uunet!mcsun!julienas!jussieu!shiva.jussieu.fr!petit
- From: petit@lirac.ibp.fr (Pascal PETIT)
- Subject: Re: Counting
- In-Reply-To: etxalve@xmas.ericsson.se's message of Wed, 20 Jan 1993 08:43:26 GMT
- Message-ID: <PETIT.93Jan21181518@lirac.ibp.fr>
- Sender: news@jussieu.fr (Le Facteur)
- Nntp-Posting-Host: lirac.ibp.fr
- Organization: LITP, IBP, Universite Pierre et Marie Curie Paris 6, 4 place
- Jussieu, 75252 PARIS CEDEX 05, France telephone : +33 (1) 44-27-61-99,
- fax: +33 (1) 44-27-40-42
- References: <18JAN199317320021@pavo.concordia.ca> <1993Jan19.140510.24158@bnr.ca>
- <etxalve.727519406@xmas>
- Date: Thu, 21 Jan 1993 17:15:18 GMT
- Lines: 44
-
- In article <etxalve.727519406@xmas> etxalve@xmas.ericsson.se (Bengt Alverborg TM/SDB 34369 2670 ( tom -> 930301 )) writes:
-
- >>I have a test file that is seperated in to columns. I would like to
- >>increment a counter when the second column(TIME) is on the hour
- >>(ex. 1:00--> i=1, 2:00 -->i=2...)
- ^ ^ # #
-
-
-
- #!/bin/awk -f
- $2 ~ /[0-9]:00/ {count++}
- END { printf "\n\nCount is:%d\n\n",count }
-
- And it will work perfectly for the second column (TIME) (hopefully)!
-
-
- it counts the number of lines. but to get the hour in an expression
- like this try :
-
- #!/bin/awk -f
- $2 ~ /[0-9]:00/ {split($2,time,/:/);i = time[1];print i}
-
- if the file is :
- adsfd 1:00
- dafhsldkj kdsflhlsd
- kjdahslka 34:00
-
-
- it will print :
- 1
- 34
-
-
-
- hope it will help.
- --
-
-
- =======================================================================
- pascal petit
- work's email : petit@litp.ibp.Fr
- petit@ccr-p6.ccr.jussieu.fr
- home's email : pascal.petit@f7.n320.z2.fidonet.org (slow but reliable)
- ======================================================================
-