0

Trivial question. What is the most elegant function myfunction that allows to produce the following output?

# myfunction "a
b
c
d"
a%0Db%0Dc%0Dd%0D
1

Using parameter expansion - substitution:

myfunction () {
    echo "${1//$'\n'/%0D}"%0D
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.