Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的老板向我提出了一个问题,即如何以一种合理便携和健壮的方式将 CRLF 序列嵌入到他的 shell 脚本中(用于管道通过某种netcat或telnet他正在做的事情)。
netcat
telnet
假设 POSIX 是“足够便携”的良好基准,
printf "\r\n"
我给他的建议:
#!/bin/sh crlf="$(echo xy | tr xy '\r\n')"
...但我愿意接受其他评论。现代版本的 GNUtr和bash.
tr
bash