findstr with hyphens
Posted: 08 Jun 2010 08:07
Hi all,
I am trying to use the findstr command to search for matches for any of the many vendors I have in another text file in a large CSV file. The command right now is:
findstr /g:Vendors.txt "ServiceRpt.csv" > out.csv
where vendors.txt contains the list of vendor names and servicerpt.csv is the large csv file.
However, some of the vendor names have hyphens and spaces in them, and the service report contains basically every ascii character possible (/\!@#$%^&*()? etc...). As a result findstr does not properly find all the entries, it finds most of them, but entries that are near or contain lines that have hyphens in them start getting ignored or other strange things start happening. Could anybody tell me what I'm missing?
ex: one of my vendor names is MTI - i, if i do findstr "MTI - i" "ServiceRpt.csv" > out.csv
it just returns ALL the lines instead of just the ones that contain MTI - i, I've also tried using the /l flag with no luck, it returns the same thing. I would like to just literally take the strings from the vendor list and match them literally to the csv file.
I am trying to use the findstr command to search for matches for any of the many vendors I have in another text file in a large CSV file. The command right now is:
findstr /g:Vendors.txt "ServiceRpt.csv" > out.csv
where vendors.txt contains the list of vendor names and servicerpt.csv is the large csv file.
However, some of the vendor names have hyphens and spaces in them, and the service report contains basically every ascii character possible (/\!@#$%^&*()? etc...). As a result findstr does not properly find all the entries, it finds most of them, but entries that are near or contain lines that have hyphens in them start getting ignored or other strange things start happening. Could anybody tell me what I'm missing?
ex: one of my vendor names is MTI - i, if i do findstr "MTI - i" "ServiceRpt.csv" > out.csv
it just returns ALL the lines instead of just the ones that contain MTI - i, I've also tried using the /l flag with no luck, it returns the same thing. I would like to just literally take the strings from the vendor list and match them literally to the csv file.