summaryrefslogtreecommitdiff
path: root/copy
blob: 8ec9a97cf948d55ebe74e97545936523a2b6073e (plain)
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
#!/usr/bin/env bash

NAME="$(basename "$0")"
FROM="$1"
TO="$2"

usage() {
    printf "Usage: %s from to\n" "$NAME"
    printf "from    The directory to copy from.\n"
    printf "to      The directory to copy to.\n"
}

if [[ ! -d "$FROM" ]];
then
    usage
    exit 1
fi

if [[ ! -d "$TO" ]];
then
    usage
    exit 1
fi

for i in {1..9};
do
    if [[ ! -e "$TO/man$i" ]];
    then
        mkdir "$TO/man$i"
    fi

    find "$FROM" -type f -name "*.$i" | xargs -I {} cp {} "$TO/man$i"
done