InterviewSolution
| 1. |
Solve : findstr vs. For /f? |
|
Answer» What should i use to strip a text file like: What should I use to strip a text file? C:\test>findstr "Secure-ID Secure-Spam-Reason" val.txt X-Secure-ID:XXXXXXXXXXXXXXXXX X-Secure-Spam-Reason: XXXXXXXXXXXXXXXXXXXXXXXX C:\test>Quote from: marvinengland on July 07, 2010, 12:20:24 PM
that you sir. you are a master mind. This just made my job a *censored* of a lot easier when i put it in a batch. Quote from: The_Valkyrie on July 06, 2010, 09:37:20 PM What should i use to strip a text file like:you use a good text PROCESSING tool, or a language that does this job well for you. For example, you can use gawk for Windows (or Perl/Python/Vbscript etc). Code: [Select]C:\test>gawk -F":" "/X-Secure-ID|X-Secure-Spam-Reason/{print $2}" file XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXX Note, the one liner above gets you the actual ID and reason, excluding X-Secure-ID and X-Secure-Spam-Reason. If you need the words "X-Secure-ID" and "X-Secure-Spam-Reason", Code: [Select]C:\test>gawk -F":" "/X-Secure-ID|X-Secure-Spam-Reason/" file X-Secure-ID:XXXXXXXXXXXXXXXXX X-Secure-Spam-Reason: XXXXXXXXXXXXXXXXXXXXXXXX ghostdog74, thanks for the brilliant reference to Gawk. I was wondering if you or anyone could help with this issue, I'm trying to output the following numbers from this text file: Analyzing pool.ntp.org (1 of 1)... delayoffset from local clock Stratum: 2 Warning: Reverse name resolution is best effort. It may not be correct since RefID field in time packets differs across NTP implementations and may not be using IP addresses. pool.ntp.org[155.101.3.115:123]: ICMP: 73ms NTP: +0.0162516s RefID: 127-67-113-92.pool.ukrtel.net [92.113.67.127] What I want is in bold. How can I do this with Gawk? With my limited knowledge I can only output: +0.0162516s RefID But I would like to have just the numbers after + Please and thanks in advance.. |
|