我有一个大文本文件(263 行),其中包含类似以下内容的行:
image_name.jpg: *lots of spaces* JPEG image data, JFIF standard 1.01, resolution (DPI), density 96x96, segment length 16, baseline, precision 8, 1024x768, frames 3 \n
image_name.jpg: *lots of spaces* JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, comment: "CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 70", progressive, precision 8, 960x540, frames 3 \n
image_name.png: *lots of spaces* PNG image data, 752 x 760, 8-bit/color RGBA, non-interlaced \n
如何删除之间的所有文本:和\n立刻?
答案1
答案2
观察Perl:
perl -pe 's/:.*//' file
或就地,留下备份文件:
perl -i.bak -pe 's/:.*//' file