Hi, I need to find a Win32 command line tool to look for a string in a text file and output x number of characters from where it found the string. For example if the file contains:
Post Comment Anonymously
I want to search for Comment and pick 6 characters after that, resulting
Anonym
Is there any tool I can use to do something like this?
Thanks and best regards,
-Sam
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I need to find a Win32 command line tool to look for a string in a text file and output x number of characters from where it found the string. For example if the file contains:
Post Comment Anonymously
I want to search for Comment and pick 6 characters after that, resulting
Anonym
Is there any tool I can use to do something like this?
Thanks and best regards,
-Sam
Download sed-4.1.2-bin.zip, sed-4.1.2-dep.zip and sed-4.1.2-doc.zip, install it and then write
sed -n ":x;s/^([^\n])Comment\s+([^\n]{0,6})[^\n]/\1\n\2/;tx;s/^[^\n]*\n//p" filename.txt
in one line in a cmd windows. For more powerful text processing there is also the package gawk.
HTH