diff --git a/ozpd/c/grep.c b/ozpd/c/grep.c
index f0cd3b4e..dc1900b1 100755
--- a/ozpd/c/grep.c
+++ b/ozpd/c/grep.c
@@ -17,6 +17,8 @@
 #include "trav.h"
 
 static int insensitive = 0;
+static int line_numbers = 0;
+static int invert_match = 0;
 static char *search;
 static char *filename = NULL;
 
@@ -28,18 +30,31 @@ static int ins_memcmp(const void *buf1, const void *buf2, int len);
 int main(int argc, char **argv)
 {
     int upto;
-    
+
     if (argc < 2)
     {
-        printf("usage: grep [-i] search files\n");
+        printf("usage: grep [-i] [-n] [-v] search files\n");
         return (0);
     }
+
     upto = 1;
-    if (strcmp(argv[upto], "-i") == 0)
+    while (upto < argc && argv[upto][0] == '-')
     {
-        insensitive = 1;
+        if (strcmp(argv[upto], "-i") == 0)
+        {
+            insensitive = 1;
+        }
+        else if (strcmp(argv[upto], "-n") == 0)
+        {
+            line_numbers = 1;
+        }
+        else if (strcmp(argv[upto], "-v") == 0)
+        {
+            invert_match = 1;
+        }
         upto++;
     }
+
     if ((argc - upto) <= 1)
     {
         dogrep(stdin, argv[upto]);
@@ -49,6 +64,7 @@ int main(int argc, char **argv)
         search = argv[upto];
         trav(argv[upto + 1], NULL, grepfile, NULL);
     }
+
     return (0);
 }
 
@@ -57,13 +73,13 @@ static int grepfile(char *file, void *ucb)
     FILE *fp;
 
     (void)ucb;
-    filename = file;    
+    filename = file;
     fp = fopen(file, "r");
     if (fp != NULL)
     {
         dogrep(fp, search);
         fclose(fp);
-    }    
+    }
     return (1);
 }
 
@@ -71,6 +87,7 @@ static void dogrep(FILE *f, char *search)
 {
     static char buf[1000];
     int found;
+    int line_number = 1;
 
     while (fgets(buf, sizeof buf, f) != NULL)
     {
@@ -89,14 +106,25 @@ static void dogrep(FILE *f, char *search)
                 found = 1;
             }
         }
+
+        if (invert_match)
+        {
+            found = !found;
+        }
+
         if (found)
         {
             if (filename != NULL)
             {
                 printf("%s: ", filename);
             }
+            if (line_numbers)
+            {
+                printf("%d: ", line_number);
+            }
             printf("%s", buf);
         }
+        line_number++;
     }
     return;
 }
@@ -106,7 +134,7 @@ static char *ins_strstr(char *buf, char *str)
     int lenb;
     int lens;
     int x;
-    
+
     lenb = strlen(buf);
     lens = strlen(str);
     for (x = 0; x <= (lenb - lens); x++)
@@ -126,7 +154,7 @@ static int ins_memcmp(const void *buf1, const void *buf2, int len)
     int ch2;
     const unsigned char *b1 = buf1;
     const unsigned char *b2 = buf2;
-    
+
     for (x = 0; x < len; x++)
     {
         ch1 = toupper(b1[x]);
