summaryrefslogtreecommitdiff
path: root/vsvs-sum
blob: faeaa16d02d0dd42bec2c7e50363f6c11c8f22c7 (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
#!/bin/bash
res=""
buf=""
while IFS="" read str
do
    if [ -z "${str##* *}" ]
    then
        key="${str%% *}"
        val="${str#* }"
    else
        key="${str}"
        val=""
    fi
    if [ -z "${key}" ]
    then
        buf="${buf}"$'\n'"${val}"
    elif [ -n "${buf}" ]
    then
        res="$(echo -n "${buf}" | $1 "${res}")"
        buf="${val}"
    fi
done
if [ -n "${buf}" ]
    res="$(echo -n "${buf}" | $1 "${res}")"
    buf="${val}"
fi
echo -n "${res}"