summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inotail.c8
-rw-r--r--inotail.h3
2 files changed, 9 insertions, 2 deletions
diff --git a/inotail.c b/inotail.c
index 1c5f8f0..123a3fa 100644
--- a/inotail.c
+++ b/inotail.c
@@ -328,8 +328,8 @@ int main(int argc, char **argv)
{
int i, c, ret = 0;
int n_files = 0;
- unsigned int n_units = DEFAULT_N_LINES;
- char forever = 0, mode = M_LINES;
+ int n_units = DEFAULT_N_LINES;
+ char forever = 0, mode = M_LINES, relative = R_END;
char **filenames;
struct file_struct *files;
@@ -339,6 +339,10 @@ int main(int argc, char **argv)
case 'n':
if (c == 'c')
mode = M_BYTES;
+ if (*optarg == '+')
+ relative = R_BEGIN;
+ else if (*optarg == '-')
+ optarg++;
n_units = strtoul(optarg, NULL, 0);
if (n_units < 0)
n_units = 0;
diff --git a/inotail.h b/inotail.h
index b47e6a4..40b0e29 100644
--- a/inotail.h
+++ b/inotail.h
@@ -7,6 +7,9 @@
/* tail modes */
enum { M_LINES, M_BYTES };
+/* tail unit relative to the end ('-' or none) or the beginning ('+' of the file) */
+enum { R_END, R_BEGIN };
+
/* Every tailed file is represented as a file_struct */
struct file_struct {
char *name; /* Name of file (or '-' for stdin) */