I am attempting to run a curl statement that I copied from Chrome DevTools. The statement has a bunch of Header parameters.

If I paste this into a Terminal window, it works great.

If I drop this into a shell script, and run the script, each line is executed as its own statement, ignoring the backslash.

curl 'https://localhost' \
  -H 'authority: localhost' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'referer: https://localhost' \
  -H 'sec-ch-ua: "Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: same-origin' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36' \

Do I need to prepend the script with something or invoke it a particular way? I don't do much shell scripting but I'm sure this is an easy one for someone to answer.


1 Answer 1


I can't say if the outcome in my question has multiple causes, but in my case, the issue was due to CRLF characters in my script: Script with CRLF line endings - Incorrect

But they should be LF characters: Script with LF line endings - Correct

I was using a Notepad++ editor running on a Windows VM and unbeknownst to me, copy/paste operations reintroduce the CRLF characters! And I often use a scratch editor tab to do various operations before dropping text into my actual script.

To avoid this issue:

  • Use a text editor on the host machine.
  • Show End-Of-Line (EOL) characters. Many editors, including Notepad++, have tools to switch between the EOL modes. But you need to know what is currently present!

Notepad++ Specific Suggestions:

  1. Change the default line endings to LF, by going to Settings -> Preferences -> New Document and change the Format(Line ending) to Unix (LF): enter image description here
  • 1
    You can configure Notepad++ to consistently use LF for the line endings (highly recommended - CRLF endings are rarely needed nowadays). The editor shows in the status line, what kind of file has been loaded, so even if you accidentally load a file into the editor which has CR, you can see it and have the editor convert it. Nov 29, 2022 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .