scp 错误:意外标记‘换行符’附近的语法错误

scp 错误:意外标记‘换行符’附近的语法错误

我正在使用 scp 将文件复制到本地计算机。该文件是一个 html 文件,我认为错误是由于 html 标记引起的,因为错误是:

 syntax error near unexpected token `newline'
 /home/admin/web/domain.tld/document_errors/50x.html-old: line 1: `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'

我怎样才能避免这样的错误?

答案1

听起来像是 Windows 行尾问题。dos2unix将解决您的问题。来自man dos2unix

   In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF). In Unix text
   files a line break is a single character: the Line Feed (LF). In Mac text files, prior to Mac OS X, a line break was single Carriage Return (CR) character. Nowadays
   Mac OS uses Unix style (LF) line breaks.

相关内容