aboutsummaryrefslogtreecommitdiff
path: root/HashProgramOutput.sh
blob: c5ac2682b320e0ceefb25a2cfa5eeb1a848e3a31 (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
#!/bin/sh

if [ $# != 1 ]; then
  echo "$0 <output path>"
  exit 1
fi

md5cmd=$(which md5sum)
is_md5sum=1
if [ ! -x "$md5cmd" ]; then
    md5cmd=$(which md5)
    is_md5sum=0
    if [ ! -x "$md5cmd" ]; then
        echo "error: unable to find either 'md5sum' or 'md5'"
        exit 1
    fi
fi

mv $1 $1.bak
if [ $is_md5sum = "0" ]; then
    $md5cmd < $1.bak > $1
else
    $md5cmd < $1.bak | cut -d' ' -f 1 > $1
fi
rm -f $1.bak