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.
我在通过 mac 或其他 linux 的 ssh 的服务器中使用 nano 时遇到问题。如果我在终端中通过 ssh 写“sleep 10”,它就可以工作。如果我执行 'echo "sleep 10" > test.sh' 和 sh test.sh,它会起作用。如果我打开 nano,写 'sleep 10' 并保存为 test.sh 并执行 'sh test.sh' 说 10\r 无效时间间隔不起作用。
有任何想法吗?
谢谢提前
听起来您正在编辑的文件在某些行的末尾已经有 \r(也称为 CR 或 ^M)
sed -i 's/\r$//' test.sh
会治愈的。