If findstr doesn't find anything it leaves a weird symbol in the file -


so if run findstr , doesn't find matching strings leaves weird symbol in file instead:

and @ end of almost of files well. there way rid of or stop happening? later have check if file empty or not set true/false , symbol screwing results. have alot of checks in same program running 1 after other, there need between them stop it?

as example, code doesn't that:

echo scanning files risks ( /f "delims=" %%a in ('findstr /i /l "android:allowbackup android:backupagent" androidmanifest.xml') (     set "line=%%a"     set "line=!line:*android:allowbackup=!"     set "line=!line:*android:backupagent=!"     /f "delims=<" %%b in (!line!) echo %%b )) > scanresults.txt 

but 1 does:

echo scanning files risks ( /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.smali') (     set "line=%%b"     set "line=!line:*web=!"     /f "delims=<>" %%b in ("!line!") echo %%a:%%b )) > scanresults.txt 

update: 2 things added still puts weird symbol text file instead of having empty

 echo scanning files risks     (     /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.smali 2^>nul') (         set "line=%%b"         set "line=!line:*web=!"         /f "delims=^<^>" %%b in ("!line!") echo %%a:%%b     )) > scanresults.txt 

update: further clarify i'm searching variety of files stated, common being json , smali files in order double check own work. searches through everything, code series of searches code above *.smali changed *.xml or *.json or whatever needed. section of code producing weird symbol in search looks this:

echo off setlocal enabledelayedexpansion  ( /f "delims=" %%a in ('findstr /i /s "web" androidmanifest.xml') ( set "line=%%a" set "line=!line:*web=!" /f "delims=<>" %%b in ("!line!") echo %%b )) > scanresults1.txt  rem scans json files ( /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.json') (     set "line=%%b"     set "line=!line:*web=!"     /f "delims=<>" %%b in ("!line!") echo %%a:%%b )) > scanresults2.txt  rem scans html files ( /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.html') (     set "line=%%b"     set "line=!line:*webv=!"     /f "delims=<>" %%b in ("!line!") echo %%a:%%b )) > scanresults3.txt  rem scans xml files ( /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.xml') (     set "line=%%b"     set "line=!line:*web=!"     /f "delims=<>" %%b in ("!line!") echo %%a:%%b )) > scanresults4.txt  rem scans smali files ( /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.smali') (     set "line=%%b"     set "line=!line:*web=!"     /f "delims=<>" %%b in ("!line!") echo %%a:%%b )) > scanresults5.txt  copy scanresults1.txt + scanresults2.txt + scanresults3.txt + scanresults4.txt + scanresults5.txt scanresultsa.txt del scanresults1.txt del scanresults2.txt del scanresults3.txt del scanresults4.txt del scanresults5.txt  :eof 

the output file looks like:

enter image description here

that's weird symbol keep getting when doesn't find anything. won't keep if copied , pasted on had picture.

if there no finds, output should empty , nothing passed (code block)
except error message findstr not redirected nul.

so append 2^>nul findstr

for /f "tokens=1*delims=:" %%a in ('findstr /i /s "web" *.smali 2^>nul') ( 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -