从文本文件的最后一行删除单双引号

时间:2017-06-14 16:49:27

标签: batch-file cmd

文本文件末尾总是有一个双引号......

"1","abc","123"
"2","abcd","456"
"3","abce","789"
"

我需要一个命令才能通过cmd.exe来删除最后一行(单引号)...

"1","abc","123"
"2","abcd","456"
"3","abce","789"

1 个答案:

答案 0 :(得分:0)

延长了我的previous answer

@echo off
copy t.txt old.txt
<nul >"new.txt" set /p x="""
>>"new.txt" (type "old.txt" |findstr /v "^.$")
rem move /y "old.txt" "new.txt"
type new.txt

附加findstr /v排除了包含单个字符的行(使用"很难处理,但我想,“单字符行”已经足够了)