-
Notifications
You must be signed in to change notification settings - Fork 1
/
journalctlf
executable file
·39 lines (32 loc) · 1 KB
/
journalctlf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# This script calls journalctl with the json output format and pipes it
# to journalfields.
# * Arguments before '--' are passed to journalctl
# * Arguments after '--' are passed to journalfields (the selected fields)
# This should probably be represented are an absolute path, so that you
# can call this script with sudo
JOURNALFIELDS=journalfields
JOURNALCTL_ARGS=( )
FIELDS=( )
# Check for help flags
for arg; do
case $arg in
-h|--help)
echo "Usage: journalctlf [ARGUMENT_FOR_JOURNALCTL]... [--] [ARGUMENT_FOR_JOURNALFIELDS]..."
echo "This is a wrapper for journalctl with journalfields."
echo "Please see the journalctl and journalfield's help message"
exit 0
;;
esac
done
# Split arguments given at the --
for arg; do
shift
if [ "$arg" = "--" ]; then
break
fi
JOURNALCTL_ARGS+=( "$arg" )
done
FIELDS=( "$@" )
echo exec journalctl -o json "${JOURNALCTL_ARGS[@]}" \| $JOURNALFIELDS "${FIELDS[@]}"
exec journalctl -o json "${JOURNALCTL_ARGS[@]}" | $JOURNALFIELDS "${FIELDS[@]}"