Using what you have, you could pipe the results through a find. I've seen something like this used from time to time. Findstr /c:'@' mail.txt find /c /v 'GarbageStringDefNotInYourResults'So you are counting the lines resulting from your findstr command that do not have the garbage string in it. Kind of a hack, but it could work for you.
![]()
Alternatively, just use the find /c on the string you do care about being there. Lastly, you mentioned one address per line, so in this case the above works, but multiple addresses per line and this breaks. Very simple solution: grep -o '@' mail.txt grep -c.Remember a dot at end of line!Here is little bit more understandable way: grep -o '@' mail.txt grep -c '@'First grep selects only '@' strings and put each on new line.Second grep counts lines (or lines with @).The grep utility can be installed from or from sites.
![]()
It is very small and safe text filter. The grep is one of most usefull Unix/Linux commands and I use it in both Linux and Windows daily.The Windows findstr is good, but does not have such features as grep.Installation of the grep in Windows will be one of the best decision if you like CLI or batch scripts. May be it's a little bit late, but the following script worked for me (the source file contained quote characters, this is why I used 'usebackq' parameter).The caret sign(^) acts as escape character in windows batch scripting language. @setlocal enableextensions enabledelayedexpansionSET TOTAL=0FOR /F 'usebackq tokens=.' %%I IN (file.txt) do (SET LN=%%IFOR%%J IN ('!LN!' ) do (FOR /F%%K IN ('ECHO%%J ^ FIND /I /C 'searchPhrase') DO (@SET /A TOTAL=!TOTAL!+%%K)))ECHO Number of occurences is!TOTAL! OK - way late to the table, but.
![]()
Every once in a while I get on a computer and I need to count the number of lines in a file. My first instinct is to open my text editor (editplus) and hit ctrl+end to get to the bottom of the document. File.txt FIND /C ':'. $ reduces the number by 1 because it is accepting the first row as Field name and then counting the number of rows.
It seems many respondents missed the original spec that all email addresses occur on 1 line. This means unless you introduce a CRLF with each occurrence of the @ symbol, your suggestions to use variants of FINDSTR /c will not help.Among the Unix tools for DOS is the very powerful SED.exe. It rocks RegEx.
@SopalajodeArrierez: Of course it is possible: grep -v '^.+' matlab.git.diff wc -l (I'm assuming the quote signs were not actually meant to be part of the line; I also assume that both lines with and without spaces in front of the + are meant to be comments; if at least one space is mandatory, either replace the star. with +, or just add another space in front of the star). Probably instead of matching only spaces, you'd want to match arbitrary whitespace; for this replace the space with :space:. Note that I've also removed matching the% since it's not in your example.–Feb 14 '15 at 15:02.
![]() Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |