本文介绍了等效于Windows上的“剪切"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件,其条目如下.
I have a file which has entries as below.
/a/b/c/d/e/f /a/b/c/g/k/l/f/j/h /a/b/c/i/m/n/p我需要Windows中的命令,该命令将从文件中删除'/a/b/c'部分.
I need a command in Windows which would remove the '/a/b/c' part from the file.
输出文件应该看起来像
d/e/f g/k/l/f/j/h i/m/n/p我尝试将for命令与/用作分隔符,但无法获得预期的结果. 我该怎么办?
I tried using the for command with / as the delimiter, but I couldn't get the expected result. How can I do this?
推荐答案@echo off (for /f "tokens=3,* delims=/" %%a in (input.txt) do echo %%b) > output.txt
技巧"是要求第三个令牌和该行的其余部分.
And the "trick" is to ask for the third token and the rest of the line.
要直接从命令行使用它:
To use it directly from the command line:
(for /f "tokens=3,* delims=/" %a in (input.txt) do @echo %b) > output.txt转义的百分号得到了简化,并且由于从命令行默认不启用echo off,因此需要在echo之前的@.
The escaped percent signs are simplified and, as from command line the echo off is not enabled by default, the @ before echo is needed.
更多推荐
等效于Windows上的“剪切"
发布评论