file_to_jsonparam (){ IFS=$'\n' OUTPUT="/tmp/file_to_jsonparam" echo "" > ${OUTPUT} cat $1 | while read LINE do ESCAPED_LINE=`echo $LINE | sed -e "s/\([\&\<\>\{\}\/]\)/__ESCAPE__\1/g" | sed -e "s/__ESCAPE__/\\\\\/g"` echo -n "${ESCAPED_LINE}\\\\r\\\\n" >> ${OUTPUT} done RESULT=`cat ${OUTPUT}` rm -f ${OUTPUT} echo ${RESULT} }