summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/journalctl.xml8
-rw-r--r--src/journal/journalctl.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/man/journalctl.xml b/man/journalctl.xml
index 109797776e..ae86c50d62 100644
--- a/man/journalctl.xml
+++ b/man/journalctl.xml
@@ -363,7 +363,9 @@
<para>If the pattern is all lowercase, matching is case insensitive. Otherwise, matching is case
sensitive. This can be overridden with the <option>--case-sensitive</option> option, see
- below.</para></listitem>
+ below.</para>
+
+ <para>When used with <option>--lines=</option>, <option>--reverse</option> is implied.</para></listitem>
</varlistentry>
<varlistentry>
@@ -540,7 +542,9 @@
<listitem><para>Show the most recent journal events and limit the number of events shown. If
<option>--follow</option> is used, this option is implied. The argument is a positive integer or
<literal>all</literal> to disable line limiting. The default value is 10 if no argument is
- given.</para></listitem>
+ given.</para>
+
+ <para>When used with <option>--grep=</option>, <option>--reverse</option> is implied.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index e10f0b7564..f148ea9144 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1084,6 +1084,11 @@ static int parse_argv(int argc, char *argv[]) {
r = pattern_compile_and_log(arg_pattern, arg_case, &arg_compiled_pattern);
if (r < 0)
return r;
+
+ /* When --grep is used along with --lines, we don't know how many lines we can print.
+ * So we search backwards and count until enough lines have been printed or we hit the head. */
+ if (arg_lines >= 0)
+ arg_reverse = true;
}
return 1;