使用sed的bash脚本在Ubuntu 15.04中不起作用

时间:2016-01-29 13:12:53

标签: bash ubuntu sed ubuntu-15.04

我有一个bash脚本,可以在文件的末尾添加几行文字。

该脚本适用于Ubuntu 14.04但不适用于15.04。

这是我使用的sed命令:

    sed -i.bak "\$a<text to add>" </absolute/path/to/file>

试图在这里检查答案,但找不到答案。有什么想法吗?

在终端中运行相同的命令。

编辑: - 更多信息

同样的脚本在编辑文件之前也会创建文件,创建工作正常。

文件创建代码:

    if [ -f "$file" ]

    then

        echo "$file found."

    else

        echo "$file not found." 

        touch $file
    fi

0 个答案:

没有答案