Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子 lines.txt 12452236400... 和documents.txt string1string2string3... 如果我有一个简短的行号列表,我可以轻松使用 sed -i’1d,4d,5d’documents.txt. 但是我必须删除很多行号.另外,我可以使用bash 我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子

lines.txt

12452236400...

和documents.txt

string1string2string3...

如果我有一个简短的行号列表,我可以轻松使用

sed -i’1d,4d,5d’documents.txt.

但是我必须删除很多行号.另外,我可以使用bash / perl脚本将行号存储在数组中,并回显不在数组中的行.但我想知道是否有内置命令来做到这一点.

任何帮助将受到高度赞赏.

解决方法 awk oneliner应该适合你,请看下面的测试:

kent$ head lines.txt doc.txt ==> lines.txt <==1357==> doc.txt <==abcdefghkent$ awk 'NR==FNR{l[
awk                     # the awk command 'NR==FNR{l[[+++]];next;}  # process the first file(lines.txt),save each line(the line# you want to delete) into an array "l" !(FNR in l)'           #Now come to the 2nd file(doc.txt),if line number not in "l",print the line out lines.txt              # 1st argument,file:lines.txt docs.txt               # 2nd argument,file:doc.txt
];next;} !(FNR in l)' lines.txt doc.txtbdfh

正如Levon所说,我补充一些解释:

[+++] 总结

以上是内存溢出为你收集整理的linux – 使用其他文件中的行号从文本文件中删除行全部内容,希望文章能够帮你解决linux – 使用其他文件中的行号从文本文件中删除行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子 lines.txt 12452236400... 和documents.txt string1string2string3... 如果我有一个简短的行号列表,我可以轻松使用 sed -i’1d,4d,5d’documents.txt. 但是我必须删除很多行号.另外,我可以使用bash 我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子

lines.txt

12452236400...

和documents.txt

string1string2string3...

如果我有一个简短的行号列表,我可以轻松使用

sed -i’1d,4d,5d’documents.txt.

但是我必须删除很多行号.另外,我可以使用bash / perl脚本将行号存储在数组中,并回显不在数组中的行.但我想知道是否有内置命令来做到这一点.

任何帮助将受到高度赞赏.

解决方法 awk oneliner应该适合你,请看下面的测试:

kent$ head lines.txt doc.txt ==> lines.txt <==1357==> doc.txt <==abcdefghkent$ awk 'NR==FNR{l[
awk                     # the awk command 'NR==FNR{l[];next;}  # process the first file(lines.txt),save each line(the line# you want to delete) into an array "l" !(FNR in l)'           #Now come to the 2nd file(doc.txt),if line number not in "l",print the line out lines.txt              # 1st argument,file:lines.txt docs.txt               # 2nd argument,file:doc.txt
];next;} !(FNR in l)' lines.txt doc.txtbdfh

正如Levon所说,我补充一些解释:

[+++] 总结

以上是内存溢出为你收集整理的linux – 使用其他文件中的行号从文本文件中删除行全部内容,希望文章能够帮你解决linux – 使用其他文件中的行号从文本文件中删除行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
linux – 使用其他文件中的行号从文本文件中删除行_系统运维_内存溢出

linux – 使用其他文件中的行号从文本文件中删除行

linux – 使用其他文件中的行号从文本文件中删除行,第1张

概述我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子 lines.txt 12452236400... 和documents.txt string1string2string3... 如果我有一个简短的行号列表,我可以轻松使用 sed -i’1d,4d,5d’documents.txt. 但是我必须删除很多行号.另外,我可以使用bash 我有一个文本文件,其中包含一个巨大的行号列表,我必须从另一个主文件中删除.这是我的数据的样子

lines.txt

12452236400...

和documents.txt

string1string2string3...

如果我有一个简短的行号列表,我可以轻松使用

sed -i’1d,4d,5d’documents.txt.

但是我必须删除很多行号.另外,我可以使用bash / perl脚本将行号存储在数组中,并回显不在数组中的行.但我想知道是否有内置命令来做到这一点.

任何帮助将受到高度赞赏.

解决方法 awk oneliner应该适合你,请看下面的测试:

kent$ head lines.txt doc.txt ==> lines.txt <==1357==> doc.txt <==abcdefghkent$ awk 'NR==FNR{l[
awk                     # the awk command 'NR==FNR{l[];next;}  # process the first file(lines.txt),save each line(the line# you want to delete) into an array "l" !(FNR in l)'           #Now come to the 2nd file(doc.txt),if line number not in "l",print the line out lines.txt              # 1st argument,file:lines.txt docs.txt               # 2nd argument,file:doc.txt
];next;} !(FNR in l)' lines.txt doc.txtbdfh

正如Levon所说,我补充一些解释:

总结

以上是内存溢出为你收集整理的linux – 使用其他文件中的行号从文本文件中删除行全部内容,希望文章能够帮你解决linux – 使用其他文件中的行号从文本文件中删除行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1032217.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存