等效于Windows上的“剪切"

编程入门 行业动态 更新时间:2024-10-22 04:46:57
本文介绍了等效于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上的“剪切"

本文发布于:2023-11-17 07:03:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609238.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!