aboutsummaryrefslogtreecommitdiff
path: root/coreutils/tail.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/tail.c')
-rw-r--r--coreutils/tail.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/coreutils/tail.c b/coreutils/tail.c
index b376ec863..19fd8f695 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -24,6 +24,9 @@
24 * 7) lseek attempted when count==0 even if arg was +0 (from top) 24 * 7) lseek attempted when count==0 even if arg was +0 (from top)
25 */ 25 */
26 26
27//kbuild:lib-$(CONFIG_TAIL) += tail.o
28//kbuild:lib-$(CONFIG_TAIL) += head_tail.o
29
27//usage:#define tail_trivial_usage 30//usage:#define tail_trivial_usage
28//usage: "[OPTIONS] [FILE]..." 31//usage: "[OPTIONS] [FILE]..."
29//usage:#define tail_full_usage "\n\n" 32//usage:#define tail_full_usage "\n\n"
@@ -34,14 +37,13 @@
34//usage: "\n -s SECONDS Wait SECONDS between reads with -f" 37//usage: "\n -s SECONDS Wait SECONDS between reads with -f"
35//usage: ) 38//usage: )
36//usage: "\n -n N[kbm] Print last N lines" 39//usage: "\n -n N[kbm] Print last N lines"
40//usage: "\n -n +N[kbm] Start on Nth line and print the rest"
37//usage: IF_FEATURE_FANCY_TAIL( 41//usage: IF_FEATURE_FANCY_TAIL(
38//usage: "\n -c N[kbm] Print last N bytes" 42//usage: "\n -c [+]N[kbm] Print last N bytes"
39//usage: "\n -q Never print headers" 43//usage: "\n -q Never print headers"
40//usage: "\n -v Always print headers" 44//usage: "\n -v Always print headers"
41//usage: "\n" 45//usage: "\n"
42//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)." 46//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)."
43//usage: "\nIf N starts with a '+', output begins with the Nth item from the start"
44//usage: "\nof each file, not from the end."
45//usage: ) 47//usage: )
46//usage: 48//usage:
47//usage:#define tail_example_usage 49//usage:#define tail_example_usage
@@ -49,13 +51,7 @@
49//usage: "nameserver 10.0.0.1\n" 51//usage: "nameserver 10.0.0.1\n"
50 52
51#include "libbb.h" 53#include "libbb.h"
52 54#include "head_tail.h"
53static const struct suffix_mult tail_suffixes[] = {
54 { "b", 512 },
55 { "k", 1024 },
56 { "m", 1024*1024 },
57 { "", 0 }
58};
59 55
60struct globals { 56struct globals {
61 bool from_top; 57 bool from_top;
@@ -102,7 +98,7 @@ static unsigned eat_num(const char *p)
102 p++; 98 p++;
103 G.from_top = 1; 99 G.from_top = 1;
104 } 100 }
105 return xatou_sfx(p, tail_suffixes); 101 return xatou_sfx(p, head_tail_suffixes);
106} 102}
107 103
108int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 104int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;