Whenever I use curl to get a file like .profile from Pastebin, the .profile file isn't read properly. I did some checking, and it seems to be down to the carriage returns.

How do I solve this problem? Can I correct the carriage returns in transit?

  • 2
    Can you add some details on how you actually use curl here and what the issue with the CRs is?
    – nohillside
    May 27, 2018 at 13:14
  • 1
    Could you add the actual command you are running and what the contents of the pastebin might be. May 27, 2018 at 23:01
  • You can find the actual command further down the page, if without the filename. May 29, 2018 at 16:50
  • I forgot to add, I see no difference in the output when I cat the file, but when I source it, I see several error messages (when not including --crlf). May 29, 2018 at 17:07

2 Answers 2


For reasons that pass understanding pastebin.com raw mode uses Windows line endings - carriage return followed by linefeed - rather than plain linefeed that is used by all right thinking operating systems.

So you need to remove the carriage returns. The easiest way to do this is using tr.

curl https://pastebin.com/raw/qg0r3wt | tr -d '\r' > .profile

That will save the contents of the pastebin qg0r3wt into the file .profile with carriage returns removed.

  • If you don't mind a friendly observation, my solution is shorter. May 29, 2018 at 16:35

The answer is to include the option --crlf in the command.

curl -o .profile --crlf https://pastebin.com/raw/...
  • 1
    That's unlikely to be the answer since the man page for curl says that that option is only for upload and only for FTP and SMTP transfers. May 27, 2018 at 23:03
  • Then maybe we have different versions of curl. It works fine at my end. May 29, 2018 at 16:48
  • I didn't work with curl v7.68.0 in Ubuntu Oct 29, 2020 at 19:50

You must log in to answer this question.

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