#!/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}" else if [ -n "${buf}" ] then res="$(echo -n "${buf}" | $1 "${res}")" fi buf="${val}" fi done if [ -n "${buf}" ] then res="$(echo -n "${buf}" | $1 "${res}")" fi echo -n "${res}"