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
user123456
  • 5,018

1 Answers1

1

Using parameter expansion - substitution:

myfunction () {
    echo "${1//$'\n'/%0D}"%0D
}
choroba
  • 47,233