问题
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.
Example:
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
Output file (op.txt) (should be)
Copy "c:\.." a b c
Copy "d:\.." a c c
Copy "e:\.." a a c
After my original code I tried to use
findstr /c:"Copy ^"" > op.txt
but this doesn't work. To let the findstr know to search a line containing Copy "
Copy[whitespace][double quote]
Updated section
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.
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
)
Thanks foxidrive for the start off and solving my first issue.
Sorry for my English, it's poor like my coding
回答1:
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
来源:https://stackoverflow.com/questions/19272357/extract-a-line-with-a-string-with-double-quote-by-using-findstr