Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 从文本文件的行中删除某些字符_File_Awk - Fatal编程技术网

File 从文本文件的行中删除某些字符

File 从文本文件的行中删除某些字符,file,awk,File,Awk,我每周都有一个由脚本生成的文本文件,其中有多行,我想去掉某些字符,这些字符每周都不同。这些文件可能看起来像这样 Community S05E05 Geothermal Escapism SD TV.avi Community S05E02 Introduction to Teaching SD TV.mp4 Supernatural S09E12 Sharp Teeth SD TV.avi Elementary S02E11 Internal Audit SD TV.mp4 我想要删除的是季/

我每周都有一个由脚本生成的文本文件,其中有多行,我想去掉某些字符,这些字符每周都不同。这些文件可能看起来像这样

Community S05E05 Geothermal Escapism SD TV.avi
Community S05E02 Introduction to Teaching SD TV.mp4
Supernatural S09E12 Sharp Teeth SD TV.avi
Elementary S02E11 Internal Audit SD TV.mp4

我想要删除的是季/集编号、质量和文件类型。如何在synology机器busybox linux上执行此操作。

鉴于您发布的有关perl解决方案的评论,听起来您只需要以下内容:

$ awk '{$2="-";NF-=2}1' file
Community - Geothermal Escapism
Community - Introduction to Teaching
Supernatural - Sharp Teeth
Elementary - Internal Audit

这个盒子上有perl吗?据我所知,Awk、sed和其他GNU工具在busybox中的功能非常有限。您期望的输出是什么?给出细节。它是这样解决的;perl-ne'/.*S..E*SD TV.*/i;打印$1-$2\n;'