Use shell parameter expansion to replace all the newlines in a text file with %0A URL encoding of a newline:OUTPUT=$(cat output.txt) FORMATTED=${OUTPUT//$'\n'/%0A}