Bash 需要使用在其他文本文件中找到的新内容更新文本文件
您好,我正在更新一个文件,从中删除一些内容,现在我必须更新一个新文件 我希望它的内容回到原始文件Bash 需要使用在其他文本文件中找到的新内容更新文本文件,bash,shell,text-files,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中的
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
或
您可以重命名newtodo.txt
mv newtodo.txt todo.txt
mv newtodo.txt todo.txt
?在我发布了我提出的问题后写下答案就用mv吧,这都是多余的。
cat newtodo.txt > todo.txt <br>