需要用在其他文本文件中找到的新内容更新文本文件
Need to update a text file with new content found in an other text file
你好,我正在更新文件,从中删除一些内容,现在我必须创建新文件
我希望它的内容回到原始文件
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
替换它们
使用 >
直接分配不起作用
cp /dev/null $file
cat $hidden | while read line
do
echo "$line" >> $file
done
您可以使用输出重定向
cat newtodo.txt > todo.txt <br>
或
您可以重命名 newtodo.txt
mv newtodo.txt todo.txt
你好,我正在更新文件,从中删除一些内容,现在我必须创建新文件 我希望它的内容回到原始文件
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
替换它们
使用 >
cp /dev/null $file
cat $hidden | while read line
do
echo "$line" >> $file
done
您可以使用输出重定向
cat newtodo.txt > todo.txt <br>
或
您可以重命名 newtodo.txt
mv newtodo.txt todo.txt