I have folder in which I have allot of different files.
I want to trim out same section in each of XXX specific files.
The name of specific files start from News-x end at News-xxx.
Content of file is like this
I need to get out only following divs boxes.<div class="col-caption">, <div class="col-1"> and <div class="col-2">
It would be nice to combine all ready files into one txt file with space between each other.
I think there is an easy way to do it in old school.
Thanks for you answer and help! I used grep before on linux, spent some time to install grep and make it work. I cannot imagine grep is doing what I want. output multiple rows of same div.
Well, I spent sometime learning and practicing but with no luck. I feel like it is a tiny part of solution.
Like in Excel you can use FIND command to locate first and last character, and MID to return content between locations.
Or grep '"col-caption\|col-1\|col-2'" News*.* > output.txt
Or grep -A5 'col-caption\|col-1\|col-2' News*.* > output.txt
Or grep -A5 '"col-caption\|col-1\|col-2'" News*.* > output.txt
Now if it must go until it finds the ending div tag, that is another story. Then you could use awk. Or write a simple parser in VB or something.
The News*.* should grep all your News files. I had forgotten to specify what to grep before.
SSupreme
ASKER
Now if it must go until it finds the ending div tag, that is another story.
Looks like I am looking for another story.
I thought I can get solution in few hours, but as usual no solution in few days.
I know I can learn grep, sed and awk, it would take few days or as I use grep, awk once a year, It would take few days to process those files manually. While I will be doing it, I will think about computer as something that hard to communicate and that is why I cannot my life simple.
http://gnuwin32.sourceforge.net/packages/grep.htm
grep col-caption *.html
would return lines having col-caption in them.
grep is a very complex tool that can quickly find search terms in text files. It has a lot of options.
To see them type
grep --help
at the command line and hit enter.
example:
grep -i (case insentive)
Another thing to note is that you can use regular expressions with grep.
http://www.opensourceforu.com/2012/06/beginners-guide-gnu-grep-basics-regular-expressions/
Once you've built grep the way you want, put
> youroutputfilename.txt
at the end of it to write to a file.
Example:
grep 'col-caption\|col-1\|col-2
or
grep -H 'col-caption\|col-1\|col-2