使用control-m字符获取意外的文件结尾

问题描述 投票:2回答:1

我有一个简单的脚本,给我一个意外的文件结束。一切似乎对我都好

#!/bin/bash
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
if [ $# -ge 5 ]; then
    echo "OK"
else
    echo "$me <arg1> <arg2> <arg3> <arg4> <arg5>"
fi

enter image description here

carriage-return
1个回答
1
投票

在用OP检查后,在评论中得知OP可能已经在你的文件中控制了M个字符使用tr -d '\r' < Input_file > temp_file && mv temp_file Input_file把你的脚本的实际名称替换为Input_file并尝试这个命令然后你就应该好了。

© www.soinside.com 2019 - 2024. All rights reserved.