-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetmantype
More file actions
executable file
·26 lines (24 loc) · 863 Bytes
/
setmantype
File metadata and controls
executable file
·26 lines (24 loc) · 863 Bytes
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
#!/bin/bash
#convert the man section type to the type provided
#setmantype <man page> type
if [ $# -ne 2 ]; then
echo "Error: invalid number of arguments, $# provided"
echo "Syntax: setmantype <man page> type"
exit
fi
manfilepath=`find . -name "$1.[0-9]" | grep -v "$1.$2"`
if [ -z "$manfilepath" ] || [ ! -f "$manfilepath" ]; then
echo "Error: $1 does not exist"
exit
fi
manfile=`basename $manfilepath`
mancommand="${manfile%.*}"
mantypeorig="${manfile##*.}"
mantypenewpath=`echo $manfilepath | sed "s/man$mantypeorig/man$2/g" | xargs -i dirname {}`
if [ ! -d "$mantypenewpath" ]; then
mkdir -p "$mantypenewpath"
fi
printf "Converting $manfilepath to $mantypenewpath/${mancommand}.$2 ... "
cat $manfilepath | sed "s/$mancommand\" $mantypeorig \"/$mancommand\" $2 \"/g" > "$mantypenewpath/${mancommand}.$2"
rm "$manfilepath"
echo "done"