Need to update a text file with new content found in an other text file

64 Views Asked by At

hello i was update a file, removing some content from it, now that i have to new file i want it's content back to the original file

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

    newtodo.txt > todo.txt

i have content in todo.txt i updated them in newtodo.txt, now i want to remove all what is in todo.txt and replace them with newtodo.txt direct assigning is not working using >

2

There are 2 best solutions below

0
On BEST ANSWER

You could use output redirection

cat newtodo.txt > todo.txt  <br>


or

You could rename newtodo.txt

mv newtodo.txt todo.txt

1
On
cp /dev/null $file

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