tag=$1 i=$2 echo "Joining <${tag}> lines in $i" sed -e :a -e "/<$tag>"'$/N;s/\n/ /;ta' $i > $i.tmp mv $i.tmp $i