我有这样的代码 -
> for line in `cat file.txt`;do
/*if line-1 dosomething-1 */
/*if line-2 dosomething-2 */
/* if line-3 dosomething-3 */
//Parsing 3 lines I would like to remove them from file - how to do that?
//Parse - line4
//Parse - line5
//Parse - line6
//now delete above 3 lines again & repeat the process till eof.\
done
我只需要在处理后删除这些行
最佳答案
您无法在读取文件时更改文件,因此您需要将要保留的条目输出到新文件(或标准输出),并跳过不需要的条目。然后可以仅使用保留的行进一步处理生成的文件。
关于linux - 读取文件后如何从文件中删除行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4813060/