home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / forum16.lzh / SOFTWARE / AWK / EXAMPLES / head < prev    next >
Text File  |  1991-05-06  |  395b  |  22 lines

  1. #
  2. # head  -  display the n first lines of a file  
  3. #
  4. # syntax: awk -f head <file> <number of display lines> 
  5. #
  6. # status:   seems OK
  7. # bug:      please tell me
  8. #                   
  9.  
  10.  
  11. BEGIN { for (i in ARGV) print i, ARGV[i] 
  12. }
  13.  
  14. {   nc = nc + length($0) + 1 
  15.     print $0  
  16.     nw = nw + NF
  17.     if (NR > (ARGV[i]-1)) exit
  18. }
  19.  
  20. END { printf("\n\n%3d lines %3d words %4d characters\n\n",NR,nw,nc ) }
  21.  
  22.