![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| My ps -ef|grep command results are chopped off | bsp18974 | UNIX for Dummies Questions & Answers | 1 | 08-14-2007 10:35 AM |
| List grep results | slire | UNIX for Dummies Questions & Answers | 14 | 10-31-2006 11:42 AM |
| How to refine results of grep -p | priceb | Shell Programming and Scripting | 2 | 06-28-2006 08:40 AM |
| grep sorting/formatting | Jaken | Shell Programming and Scripting | 10 | 05-13-2006 02:36 PM |
| Question about formatting results | TheCrunge | UNIX for Dummies Questions & Answers | 5 | 02-23-2005 08:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Multiple Grep Results - Formatting
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. Examples: Basic command: cat file.txt > grep -i CAT > results.txt file.txt: The cat said meow The cat was hungry results.txt: The cat said meow The cat was hungry desired results: The cat said meow The cat was hungry Thanks to anyone who can help ![]() -Sys |
|
||||
|
Quote:
|
|
||||
|
UPDATE:
I did find one way of doing this successfully. I was able to limit my results to one line per instance found by running this on the output file: cat myfile.txt | sed 's/$/<br>/' > myfile.txt This adds the text "<br>" to the end of each line and works quite well. Hopefully somone else will find this useful. If anyone has any other ideas, that would be cool as well. ![]() |
|
||||
|
Quote:
cat file.txt | grep -i CAT > myfile.html on this file: The cat says meow The cat is hungry 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. ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|