【问题标题】:Add a new text line with an existing text file by command line ubuntu 14.04通过命令行 ubuntu 14.04 添加带有现有文本文件的新文本行
【发布时间】:2015-03-15 07:16:15
【问题描述】:

我有一个包含一些单词的文本文件。我想添加一些其他单词而不用 linux 命令行删除以前的单词。 我用
echo "hello everyone" > abc.txt
写入文件 abc.txt "hello 大家"(不带引号)但删除之前的所有单词。 我该如何预防?我只想在前面的单词中添加“大家好”。

【问题讨论】:

    标签: linux file shell command-line


    【解决方案1】:

    使用“>>”将内容附加到文件末尾,例如:

    echo "hello everyone" >> abc.txt
    

    ">" 将删除现有内容,然后在 abc.txt 中写上大家好。

    【讨论】:

      【解决方案2】:

      > 截断文件然后写入,>> 追加。将> 更改为>>,您将获得金奖。

      【讨论】:

        猜你喜欢
        • 2020-06-11
        • 2014-05-23
        • 1970-01-01
        • 1970-01-01
        • 2015-06-02
        • 1970-01-01
        • 2011-03-10
        • 2017-04-10
        • 1970-01-01
        相关资源
        最近更新 更多