Created
October 18, 2022 16:43
-
-
Save balki/f07deef358400427788fa58740a8ef22 to your computer and use it in GitHub Desktop.
Get Systemd directive help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Usage: | |
# systemd-search.sh WorkingDirectory | |
word=$1 | |
get_doc() { | |
exec {awkfd}<<AWKS | |
/^ ((${word}=(, [A-Z])?)|(([^ ]+=, )+${word}=))/ , /^[^ ]/ { | |
if(headerLineDone) { | |
if (/^ [^ ]+=/) | |
exit | |
} else { | |
if (/^ /) | |
headerLineDone = 1 | |
} | |
print; | |
} | |
AWKS | |
awk -f /dev/fd/$awkfd | grep -v "^[^ ]" | sed 's/^ //' | |
exec {awkfd}>&- | |
} | |
COLUMNS=1000 man systemd.directives 2>/dev/null | | |
awk /^UNIT/,/^OPT/ | | |
grep -A1 -- " $word" | | |
sed -n 2p | | |
tr ',' '\n' | | |
sed 's/ //g' | | |
sed 's/.5.//g' | | |
while read -r manf | |
do | |
echo "<=== $manf ===>" | |
man "$manf" 2>/dev/null | get_doc | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment