Forum Moderators: bakedjake

Message Too Old, No Replies

More fun with bash, strings with multiple lines

         

csdude55

7:21 am on Dec 11, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm running cURL in bash, and in that cURL is a string. So it looks like this:

waf[exploitA]=$(curl https://foo.com \
--data '{
"description": "Blah",
"expression": "Lorem ipsum"
}'


The cURL will print "Lorem ipsum" verbatim.

The question is, what's the best option if I wanted it to print it on two lines? Eg,

Lorem
Ipsum

Can I just do this in bash, with the `accent` or whatever it's called?

"expression": `Lorem
ipsum`


Or do I have to make it the harder-to-read:

"expression": "Lorem\nipsum"


Or something else?

csdude55

5:48 am on Dec 12, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For future readers, I've tried every option I could think of and the hard-to-read "Lorem\nipsum" is the only solution that seems to have worked :-/ I'd love to hear it if anyone comes up with a better alternative, though! Since I'm using Cloudflare, using bash for their API is becoming a new way of life for me.