#!/bin/bash # sd-list-dependencies-extra - augment output of `systemctl list-dependencies` # The current version adds to each line the values of selected unit options # (if defined in the respective unit file). # The unit options to select (regexps) MATCH_OPTIONS=('Condition.*=' 'Exec.*=') filter_unit_options() { local IFS='|' systemctl cat -- "$1" | grep -E "^(${MATCH_OPTIONS[*]})" } augment_output() { local line unit opts while read line; do unit=$(grep -o '[-.[:alnum:]]*$' <<<"$line") opts=$(filter_unit_options "$unit" | sed -e 's/^/[/; s/$/]/' | tr '\n' ' ') echo "$line $opts" done } systemctl --no-pager list-dependencies $1 | augment_output