The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 -->
  #6 (permalink)  
Old 02-12-2009
marcelino marcelino is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
response

Using the same data you had example, I got the following:

nawk 'BEGIN {RS=FS=""} {print $1, NF-1}' data.txt
0 27
0 31

Adding space to ""

$ nawk 'BEGIN {RS=FS=" "} {print $1, NF-1}' data.txt
01.02.09 0
08:30 4
07:00 4

Changing to NF-2

$ nawk 'BEGIN {RS=FS=" "} {print $1, NF-2}' data.txt
01.02.09 -1
08:30 3
07:00 3