简体   繁体   English

删除Windows批处理中文件的最后一个换行符

[英]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.

相关问题 从Windows批处理文件中的字符串中删除第一个和最后一个字符 - Remove first and last character from a String in a Windows Batch file 从Windows Batch中的文件中删除一行 - Remove a line from a file in Windows Batch 如何使用批处理脚本从文件中删除第一个和最后一个字符? - How to remove the first and last character from a file using batch script? 如何在 windows 批处理脚本中连接换行符 - How to concat new line character in windows batch script 获取 windows 批处理文件中的最后一个命令行参数 - Get last command line argument in windows batch file 如何在Windows批处理文件中使用“输入”(换行)将文件合并为一个? - How to merge file in to one with “enter”(New line) in windows batch file? 使用 Windows 批处理文件在文本文件中添加新行 - Add new line in text file with Windows batch file 批处理将几个.txt文件的最后一行复制到1个新的.txt文件中,并在新行上附加文件名 - batch to copy last line of several .txt files into 1 new .txt file and appends file name on new line 我想使用批处理脚本/cmd 从目录中的每个 txt 文件中删除最后一个字符 - I want to remove last character from each txt file in a directory using batch script/cmd 从批处理文件中的变量中删除最后一个字符 - Removing last character from a variable in a Batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM