安装与转换
安装与转换
dnf install -y dos2unix # UOS/Ubuntu 系: apt install -y dos2unix
dos2unix /opt/app/bin/start.sh
file /opt/app/bin/start.sh # 应为 ASCII/UTF-8 text,不含 CRLF 字样批量处理
批量处理
find /opt/app -type f -name '*.sh' -print0 | xargs -0 dos2unix
# 备选:sed -i 's/\r$//' file.sh
# vim 内查看转换::set ff? 然后 :set ff=unix 保存CRLF 同样会影响 systemd unit、crontab 行、脚本首行 shebang:批量迁移后逐类抽查。