ScriptB 有 CRLF 行结尾。由于内核不支持 CRLF,它试图执行一个名为"/path/to/bin/perl\r"(其中\r表示 CR)的程序。那个程序不存在。将 ScriptB 转换为 LF 行尾。(感谢斯蒂芬Chazelas的问正确的问题,该\r在sed输出指示的问题。)
sed l\;q FILE运行 2 个 sed 命令(用分号分隔,需要转义,因为它也是一个 shell 元字符)。来自man sed:
l List out the current line in a "visually unambiguous" form
q Immediately quit the sed script without processing any more input,
except that if auto-print is not disabled the current pattern space will be printed.
Run Code Online (Sandbox Code Playgroud)
因此l,以一种使 CR 等通常隐藏的字符可见的格式打印第一行,然后q在第一行之后退出。