需要使用在其他文本文件中找到的新内容更新文本文件

时间:2015-06-17 10:39:39

标签: bash shell text-files

你好我更新了一个文件,从中删除了一些内容,现在我必须要新文件 我希望它的内容回到原始文件

    hidden=Desktop/newtodo.txt    
    do
        echo -e "$y \t $line" >> $hidden
        y=$(($y+1))
    done

    newtodo.txt > todo.txt

我在todo.txt中有内容我在newtodo.txt更新了它们,现在我想删除todo.txt中的所有内容并将其替换为newtodo.txt 直接分配无法使用>

2 个答案:

答案 0 :(得分:1)

您可以使用输出重定向

cat newtodo.txt > todo.txt  <br>




您可以重命名newtodo.txt

  

mv newtodo.txt todo.txt

答案 1 :(得分:-1)

cp /dev/null $file

cat $hidden | while read line
do
    echo "$line" >> $file
done