Hello group,
We have a script that compares a file of email addresses (dump.txt) with a list of employees (pwd_raw.txt).
findstr /g:"dump.txt" "pwd_raw.txt" >output.txt
The file of email addresses has the email addresses, one per line, BUT it also includes a comma "," at the end of each line, immediately after the email address:
john.doe@company.com,
jenny.jones@company.com,
Because the list of employees in pwd_raw.txt does not include the comma "," the findstr is failing.
Our corporate IT policies are very strict and we cannot use apps that could easily remove the comma, such as FART or sfk.
Is there a way to:
1 - trim the comma from the email addresses
OR
2 - ignore the comma from the findstr
I have certainly been researching, including https://ss64.com/nt/findstr.html but have yet to find an answer I am able to use.
Any help would be appreciated.
Aisha
findstr because of extra comma
Moderator: DosItHelp
Re: findstr because of extra comma
I assume that would work for you:
Of course it will take longer because findstr.exe has to be executed for each line in dump.txt.
Steffen
Code: Select all
>"output.txt" (
for /f "usebackq delims=," %%i in ("dump.txt") do findstr /c:"%%i" "pwd_raw.txt"
)
Steffen
-
- Posts: 6
- Joined: 26 Sep 2016 15:02
Re: findstr because of extra comma
many thanks - I have not seen code that starts with the intended filename at the beginning before - did not know that was possible.
so much still to learn
thanks
so much still to learn
thanks
Re: findstr because of extra comma
viewtopic.php?f=3&t=8305
In your case it really doesn't matter if you write the redirection in front of the left parenthesis or after the right parenthesis. Meanwhile it's just one of my habits to always write redirections at the beginning of the line.
Steffen
In your case it really doesn't matter if you write the redirection in front of the left parenthesis or after the right parenthesis. Meanwhile it's just one of my habits to always write redirections at the beginning of the line.
Steffen