Command to filter log
We may need to send a large number of log files out of office, but those log may contains sensitive or private data. The below command in Windows batch (tested under Windows 7)
for /r %f in (Sever*.log) do type %~nf.log | findstr /v "PrivateContent" > Filtered_%~nf.log
for /r %f in (Sever*.log) do type %~nf.log | findstr /v "PrivateContent" > Filtered_%~nf.log
- The for /r list all files in current folder.
- (Server*.log) is my filter criteria. You may change your own according to your need.
- %f extract the each file name with full path
- %~nf extract only file name (without path and extension).
- | (pipe) redirect output from type command to findstr
- findstr /v is to filter out lines with "PrivateContent"
- "PrivateContent": you may change your keyword according to your need. e.g. password, account number, etc.
- > redirect the output to a new file.
- The new file will be named Filterd_ServerXXXXX.log.
Comments