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 '18 at 13:14
  • 1
    Could you add the actual command you are running and what the contents of the pastebin might be. – Tony Williams May 27 '18 at 23:01
  • You can find the actual command further down the page, if without the filename. – Bert Visscher May 29 '18 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). – Bert Visscher May 29 '18 at 17:07

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.

| improve this answer | |
  • If you don't mind a friendly observation, my solution is shorter. – Bert Visscher May 29 '18 at 16:35

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

curl -o .profile --crlf https://pastebin.com/raw/...
| improve this answer | |
  • 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. – Tony Williams May 27 '18 at 23:03
  • Then maybe we have different versions of curl. It works fine at my end. – Bert Visscher May 29 '18 at 16:48

You must log in to answer this question.

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