Hello,
Perhaps someone here can help with this. I'd like to grep a plain text file for a word and output each line containing a word found to a seperate line instead of back to back.
Yes, perhaps my example was a bit too simplified for the task. I usually try to truncate the details a bit with my posts so the information isn't too confusing for anyone trying to read it. Basically, the script finds more than one instance of the word "cat" and does return the output to a line each result, but I am trying to use the output for an HTML page and I'd like to format the output to be one result per line and it seems to be mashing it all together. My apologies for the confusion.
And open this file in a web browser, it ends up putting the search results formatted back to back.
Like this:
The cat says meow The cat is hungry
Even if the file myfile.html looks like this:
The cat saws meow
The cat is hungry
So I ran the previous command to append "<br>" to the end of each line, so the web browser would seperate each line appropriately.
Again, I hope somone else finds my dilemma/resolution useful. I would still like to find a way of doing this in line with the grep command though, not after the file has been generated if anyone has any hints.