Skip to content

Commit

Permalink
Merge pull request #30241 from poettering/journalctl-short-file-switch
Browse files Browse the repository at this point in the history
journalctl: add short option "-i" for "--file="
  • Loading branch information
DaanDeMeyer committed Dec 6, 2023
2 parents f8d6713 + dde54b8 commit 8e3dc73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions man/journalctl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<emphasis>are</emphasis> being shown.</para>

<para>The set of journal files which will be used can be modified using the <option>--user</option>,
<option>--system</option>, <option>--directory</option>, and <option>--file</option> options, see
<option>--system</option>, <option>--directory=</option>, and <option>--file=</option> options, see
below.</para>

<para>All users are granted access to their private per-user journals. However, by default, only root and
Expand Down Expand Up @@ -160,6 +160,7 @@
</varlistentry>

<varlistentry>
<term><option>-i <replaceable>GLOB</replaceable></option></term>
<term><option>--file=<replaceable>GLOB</replaceable></option></term>

<listitem><para>Takes a file glob as an argument. If specified, journalctl will operate on the
Expand Down Expand Up @@ -295,7 +296,7 @@
<constant>2</constant> the second and so on; while <constant>-0</constant> is the last boot,
<constant>-1</constant> the boot before last, and so on. An empty <replaceable>offset</replaceable>
is equivalent to specifying <constant>-0</constant>, except when the current boot is not the last
boot (e.g. because <option>--directory</option> was specified to look at logs from a different
boot (e.g. because <option>--directory=</option> was specified to look at logs from a different
machine).</para>

<para>If the 32-character <replaceable>ID</replaceable> is specified, it may optionally be followed
Expand Down
9 changes: 4 additions & 5 deletions src/journal/journalctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ static int help(void) {
" -M --machine=CONTAINER Operate on local container\n"
" -m --merge Show entries from all available journals\n"
" -D --directory=PATH Show journal files from directory\n"
" --file=PATH Show journal file\n"
" -i --file=PATH Show journal file\n"
" --root=PATH Operate on an alternate filesystem root\n"
" --image=PATH Operate on disk image as filesystem root\n"
" --image-policy=POLICY Specify disk image dissection policy\n"
Expand Down Expand Up @@ -461,7 +461,6 @@ static int parse_argv(int argc, char *argv[]) {
ARG_HEADER,
ARG_FACILITY,
ARG_SETUP_KEYS,
ARG_FILE,
ARG_INTERVAL,
ARG_VERIFY,
ARG_VERIFY_KEY,
Expand Down Expand Up @@ -514,7 +513,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "system", no_argument, NULL, ARG_SYSTEM },
{ "user", no_argument, NULL, ARG_USER },
{ "directory", required_argument, NULL, 'D' },
{ "file", required_argument, NULL, ARG_FILE },
{ "file", required_argument, NULL, 'i' },
{ "root", required_argument, NULL, ARG_ROOT },
{ "image", required_argument, NULL, ARG_IMAGE },
{ "image-policy", required_argument, NULL, ARG_IMAGE_POLICY },
Expand Down Expand Up @@ -565,7 +564,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);

while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:g:c:S:U:t:u:NF:xrM:", options, NULL)) >= 0)
while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:g:c:S:U:t:u:NF:xrM:i:", options, NULL)) >= 0)

switch (c) {

Expand Down Expand Up @@ -727,7 +726,7 @@ static int parse_argv(int argc, char *argv[]) {
arg_directory = optarg;
break;

case ARG_FILE:
case 'i':
if (streq(optarg, "-"))
/* An undocumented feature: we can read journal files from STDIN. We don't document
* this though, since after all we only support this for mmap-able, seekable files, and
Expand Down

0 comments on commit 8e3dc73

Please sign in to comment.