[英]Remove last new line character of a file in windows batch
I have around 1340 * 2 GB files in recursive directories. 我在递归目录中大约有1340 * 2 GB的文件。 I need to remove the last new line character (only once even if it has multiple new line characters) of every file if exists. 我需要删除每个文件的最后一个换行符(即使有多个换行符,也只能删除一次)(如果存在)。
Since these are huge files, please let me know the way to delete the last new line character without reading entire file into memory, something similar to sed command sed '$ { /^$/ d}' *
由于这些文件很大,请让我知道在不将整个文件读入内存的情况下删除最后一个换行符的方法,类似于sed命令sed '$ { /^$/ d}' *
Any help will be highly appreciated. 任何帮助将不胜感激。 Please see me as novice to batch and windows 请视为批处理和Windows的新手
这个给你
sed 'N; $!P; $!D; $s/\n//'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.