通过使用FINDSTR提取用双引号串线 [英] Extract a line with a string with double quote by using findstr

查看:304
本文介绍了通过使用FINDSTR提取用双引号串线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先感谢您对本网站,我是一个可怕的codeR,所以我需要制作一个批处理脚本你们的帮助,我尝试提取包含复制,在该行从一个文本文件只行通过使用FINDSTR实际上没有工作的空白和双引号,但它会提取符合复制和帮助过,我不需要。

First of all thank you for this site, I'm a terrible coder and so i need your help with making a batch script, i try to extract only lines that contains Copy " in that line from a text file by using findstr which actually works without that whitespace and double quote. But it will extract the line with "Copy and Help" too which i don't need.

例如:

我的文字中包含(的Source.txt)

My text contains (source.txt)

a
asd Copy and help with these command prompt:
a
  asd Copy "c:\.." a b c(white space)
a
 asd Copy and help with these command prompt:
Copy "d:\.." a c c(tab space)
avs
    Copy "e:\.." a a c
vvddf

输出文件(op.txt)(应该是)

Output file (op.txt) (should be)

Copy "c:\.." a b c
Copy "d:\.." a c c
Copy "e:\.." a a c

我原来的code后,我试图用

After my original code I tried to use

findstr /c:"Copy ^"" > op.txt

但是,这并不正常工作。为了让FINDSTR知道搜索包含

but this doesn't work. To let the findstr know to search a line containing

Copy "

复制[行空格] [双引号]

Copy[whitespace][double quote]

更新部分

Updated section

首先我需要批处理脚本是从帮助下foxidrive工作。还有一些好办法的事,但我将发布它作为一个问题。这个问题的答案。

First off my required batch script is working from help by foxidrive. There is still some tweak to do, but i will post it as another question. This question is answered.

这是我更新code现在。

This is my updated code for now.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET source="details.txt"
IF EXIST %source% (
  FIND /i "copy " <%source% |FIND "\" >op.txt
) ELSE (
  Exit
)

感谢foxidrive的开始,解决我的第一个问题。

Thanks foxidrive for the start off and solving my first issue.

对不起,我的英语水平,这可怜的就像我的编码

推荐答案

一个简单的解决办法就是用这种

A simplistic solution is to use this

find ":\" <source.txt  >op.txt

或者这是另一种解决办法:

Or this is another workaround:

find ":\" <source.txt |find /i "copy " >op.txt

这篇关于通过使用FINDSTR提取用双引号串线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆