diff -urN pv-1.0.1.orig/doc/quickref.1.in pv-1.0.1/doc/quickref.1.in
--- pv-1.0.1.orig/doc/quickref.1.in	2007-08-03 23:40:52.000000000 +0100
+++ pv-1.0.1/doc/quickref.1.in	2007-08-07 17:13:40.000000000 +0100
@@ -101,6 +101,10 @@
 Turn the rate counter on.  This will display the current rate of data
 transfer.
 .TP
+.B \-l, \-\-lines
+Turn the line rate counter on.  This will display the current rate of lines
+being transferd.
+.TP
 .B \-b, \-\-bytes
 Turn the total byte counter on.  This will display the total amount of
 data transferred so far.
diff -urN pv-1.0.1.orig/README pv-1.0.1/README
--- pv-1.0.1.orig/README	2007-08-02 18:33:58.000000000 +0100
+++ pv-1.0.1/README	2007-08-07 17:16:33.000000000 +0100
@@ -89,4 +89,7 @@
   Gert Menke
     - reported bug when piping to dd with a large input buffer size
 
+  Thomas Stewart <thomas@stewarts.org.uk
+    - added line rate counter
+
 -----------------------------------------------------------------------------
diff -urN pv-1.0.1.orig/src/include/options.h pv-1.0.1/src/include/options.h
--- pv-1.0.1.orig/src/include/options.h	2007-08-02 22:29:19.000000000 +0100
+++ pv-1.0.1/src/include/options.h	2007-08-07 16:57:09.000000000 +0100
@@ -21,6 +21,7 @@
 	unsigned char timer;           /* timer flag */
 	unsigned char eta;             /* ETA flag */
 	unsigned char rate;            /* rate counter flag */
+	unsigned char lines;            /* rate counter flag */
 	unsigned char bytes;           /* bytes transferred flag */
 	unsigned char force;           /* force-if-not-terminal flag */
 	unsigned char cursor;          /* whether to use cursor positioning */
diff -urN pv-1.0.1.orig/src/include/pv.h pv-1.0.1/src/include/pv.h
--- pv-1.0.1.orig/src/include/pv.h	2007-08-02 22:02:25.000000000 +0100
+++ pv-1.0.1/src/include/pv.h	2007-08-07 16:57:09.000000000 +0100
@@ -24,8 +24,8 @@
 void pv_calc_total_size(opts_t);
 
 int pv_main_loop(opts_t);
-void pv_display(opts_t, long double, long long, long long);
-long pv_transfer(opts_t, int, int *, int *, unsigned long long);
+void pv_display(opts_t, long double, long long, long long, long long, long long);
+long pv_transfer(opts_t, int, int *, int *, unsigned long long, long *);
 void pv_set_buffer_size(unsigned long long, int);
 int pv_next_file(opts_t, int, int);
 
diff -urN pv-1.0.1.orig/src/main/help.c pv-1.0.1/src/main/help.c
--- pv-1.0.1.orig/src/main/help.c	2007-08-04 21:37:30.000000000 +0100
+++ pv-1.0.1/src/main/help.c	2007-08-07 16:57:09.000000000 +0100
@@ -35,6 +35,8 @@
 		 _("show estimated time of arrival (completion)")},
 		{"-r", "--rate", 0,
 		 _("show data transfer rate counter")},
+		{"-l", "--lines", 0,
+		 _("show lines transfer rate counter")},
 		{"-b", "--bytes", 0,
 		 _("show number of bytes transferred")},
 		{"-f", "--force", 0,
diff -urN pv-1.0.1.orig/src/main/options.c pv-1.0.1/src/main/options.c
--- pv-1.0.1.orig/src/main/options.c	2007-08-04 21:37:30.000000000 +0100
+++ pv-1.0.1/src/main/options.c	2007-08-07 16:57:09.000000000 +0100
@@ -55,6 +55,7 @@
 		{"timer", 0, 0, 't'},
 		{"eta", 0, 0, 'e'},
 		{"rate", 0, 0, 'r'},
+		{"lines", 0, 0, 'l'},
 		{"bytes", 0, 0, 'b'},
 		{"force", 0, 0, 'f'},
 		{"numeric", 0, 0, 'n'},
@@ -72,7 +73,7 @@
 	};
 	int option_index = 0;
 #endif
-	char *short_options = "hVpterbfnqcWs:i:w:H:N:L:B:";
+	char *short_options = "hVpterlbfnqcWs:i:w:H:N:L:B:";
 	int c, numopts;
 	opts_t opts;
 
@@ -141,6 +142,10 @@
 			opts->rate = 1;
 			numopts++;
 			break;
+		case 'l':
+			opts->lines = 1;
+			numopts++;
+			break;
 		case 'b':
 			opts->bytes = 1;
 			numopts++;
diff -urN pv-1.0.1.orig/src/pv/display.c pv-1.0.1/src/pv/display.c
--- pv-1.0.1.orig/src/pv/display.c	2007-08-04 21:37:30.000000000 +0100
+++ pv-1.0.1/src/pv/display.c	2007-08-07 17:00:34.000000000 +0100
@@ -87,15 +87,18 @@
  *
  * If "opts" is NULL, then free all allocated memory and return.
  */
-void pv_display(opts_t opts, long double esec, long long sl, long long tot)
+void pv_display(opts_t opts, long double esec, long long sl, long long lsl,
+                long long tot, long long ltot)
 {
 	static long percentage = 0;
 	static long double prev_esec = 0;
 	static long double prev_rate = 0;
 	static long double prev_trans = 0;
+	static long double prev_lines_rate = 0;
+	static long double prev_lines = 0;
 	static char *display = NULL;
 	static long dispbufsz = 0;
-	long double sincelast, rate, transferred;
+	long double sincelast=0, rate=0, lines_rate=0, transferred;
 	long eta;
 	char prefix[128];		 /* RATS: ignore (checked OK) */
 	char suffix[128];		 /* RATS: ignore (checked OK) */
@@ -129,6 +132,23 @@
 	}
 	prev_rate = rate;
 
+	if (lsl >= 0) {
+		if (sincelast <= 0.01) {
+			lines_rate = prev_lines_rate;
+			prev_lines += lsl;
+		} else {
+			lines_rate = ((long double) lsl + prev_lines) /
+				sincelast;
+			prev_esec = esec;
+			prev_lines = 0;
+		}
+	} else {
+		if (esec < 0.000001)
+			esec = 0.000001;
+		rate = ((long double) ltot) / (long double) esec;
+	}
+	prev_lines_rate = lines_rate;
+                
 	if (rate > 0)
 		percentage += 2;
 	if (percentage > 199)
@@ -243,6 +263,13 @@
 		strcat(display, prefix);    /* RATS: ignore (OK) */
 	}
 
+	if (opts->lines) {
+		if (lines_rate > 100000)
+			lines_rate = 100000;
+		sprintf(prefix, "[%Lg lines/s]", lines_rate);
+		strcat(display, prefix);    /* RATS: ignore (OK) */
+	}
+
 	suffix[0] = 0;
 	if (opts->eta && opts->size > 0) {
 		if (eta < 0)
diff -urN pv-1.0.1.orig/src/pv/loop.c pv-1.0.1/src/pv/loop.c
--- pv-1.0.1.orig/src/pv/loop.c	2007-08-04 21:37:30.000000000 +0100
+++ pv-1.0.1/src/pv/loop.c	2007-08-07 17:08:16.000000000 +0100
@@ -31,8 +31,9 @@
  */
 int pv_main_loop(opts_t opts)
 {
-	long written;
+	long written, lines;
 	long long total_written, since_last, cansend, donealready, target;
+	long long total_lines, lines_since_last;
 	int eof_in, eof_out, final_update;
 	struct timeval start_time, next_update, next_reset, cur_time;
 	struct timeval init_time;
@@ -48,6 +49,8 @@
 	eof_out = 0;
 	total_written = 0;
 	since_last = 0;
+	total_lines = 0;
+	lines_since_last = 0;
 
 	gettimeofday(&start_time, NULL);
 	gettimeofday(&cur_time, NULL);
@@ -96,13 +99,17 @@
 				cansend = 0;
 		}
 
-		written =
-		    pv_transfer(opts, fd, &eof_in, &eof_out, cansend);
+		written = pv_transfer(opts, fd, &eof_in, &eof_out, cansend,
+			&lines);
 		if (written < 0)
 			return 1;
 
 		since_last += written;
 		total_written += written;
+
+		lines_since_last += lines;
+		total_lines += lines;
+
 		if (opts->rate_limit > 0)
 			donealready += written;
 
@@ -212,17 +219,21 @@
 		elapsed +=
 		    (cur_time.tv_usec - init_time.tv_usec) / 1000000.0;
 
-		if (final_update)
+		if (final_update) {
 			since_last = -1;
+			lines_since_last = -1;
+		}
 
 		if (pv_sig_newsize) {
 			pv_sig_newsize = 0;
 			pv_screensize(opts);
 		}
 
-		pv_display(opts, elapsed, since_last, total_written);
+		pv_display(opts, elapsed, since_last, lines_since_last,
+			total_written, total_lines);
 
 		since_last = 0;
+		lines_since_last = 0;
 	}
 
 	if (opts->cursor) {
@@ -236,8 +247,8 @@
 	 * Free up the buffers used by the display and data transfer
 	 * routines.
 	 */
-	pv_display(0, 0, 0, 0);
-	pv_transfer(0, -1, 0, 0, 0);
+	pv_display(0, 0, 0, 0, 0, 0);
+	pv_transfer(0, -1, 0, 0, 0, 0);
 
 	return 0;
 }
diff -urN pv-1.0.1.orig/src/pv/transfer.c pv-1.0.1/src/pv/transfer.c
--- pv-1.0.1.orig/src/pv/transfer.c	2007-08-04 21:37:30.000000000 +0100
+++ pv-1.0.1/src/pv/transfer.c	2007-08-07 17:09:26.000000000 +0100
@@ -54,7 +54,7 @@
  * returned.
  */
 long pv_transfer(opts_t opts, int fd, int *eof_in, int *eof_out,
-		 unsigned long long allowed)
+		 unsigned long long allowed, long *lines_read)
 {
 	static unsigned char *buf = NULL;
 	static unsigned long in_buffer = 0;
@@ -65,7 +65,7 @@
 	int max_fd;
 	long to_write, written;
 	ssize_t r, w;
-	int n;
+	int i, n;
 
 	if (opts == NULL) {
 		if (buf)
@@ -128,6 +128,7 @@
 		return -1;
 	}
 
+	*lines_read = 0;
 	written = 0;
 
 	if (FD_ISSET(fd, &readfds)) {
@@ -161,6 +162,14 @@
 		}
 	}
 
+	if(opts->lines) {
+		for(i=bytes_written; i < to_write; i++) {
+			if(buf[bytes_written + i] == '\n') {
+				(*lines_read)++;
+			}
+		}
+	}
+
 	if (FD_ISSET(STDOUT_FILENO, &writefds)
 	    && (in_buffer > bytes_written)
 	    && (to_write > 0)) {

