Skip to content

Instantly share code, notes, and snippets.

@x3ric
Created June 10, 2024 15:45
Show Gist options
  • Save x3ric/6f4910563c3c9fb38120b77f42eb6f94 to your computer and use it in GitHub Desktop.
Save x3ric/6f4910563c3c9fb38120b77f42eb6f94 to your computer and use it in GitHub Desktop.
Local Man Pages TXT
#!/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Please run this script with sudo."
exit 1
fi
mkdir -p "/home/$(logname)/man"
cd "/home/$(logname)/man"
filename="manpagelist.csv"
manpath=$(manpath)
IFS=':' read -r -a paths <<< "$manpath"
for path in "${paths[@]}"; do
find "$path" -type f -name '*.[0-9]*' | while read -r manpage; do
base=$(basename "$manpage")
name="${base%.*}"
echo "$name"
done
done | sort | uniq > "$filename"
while IFS=""; read -r manpagename; do
\man $manpagename > $manpagename.txt
done < $filename
echo "Done... Text files located in $(pwd)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment