The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 02-12-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by marcelino View Post
Nice...

I had to add space to "" and change NF-1 to NF-2 to get accurate count for all lines except the last and first entry. NF-1 gives the correct output for the last line count only. I have 9,000 lines so I having the last and first wrong is not significant issue.

The next problem is that output only has the time in the line like this:

10:00 4
11:00 6

I need the date in the output. Currently looking through the nawk manual to figure out how to combine time and date into output. Any quick suggestions? BTW, running nawk 1.3.3 from Ubuntu 8.10
Hmmm.. very strange...
mar.txt:

Code:
01.02.09 08:30
bob
jill
mark

01.04.09 07:00
bob
jill
mark
tom

nawk 'BEGIN {RS=FS=""} {print $1, NF-1}' mar.txt

output:

Code:
01.02.09 08:30 3
01.04.09 07:00 4

Looks fine to me. Post your input file (or a portion of it) using vB Code tags.