![]() |
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 |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Substr throws an ERROR. Any alternatives? | naseert | Shell Programming and Scripting | 3 | 05-08-2008 12:34 PM |
| double dashes | systemsb | UNIX for Dummies Questions & Answers | 2 | 05-18-2006 10:41 AM |
| help removing dashes from social security number | Marcia P | UNIX for Dummies Questions & Answers | 2 | 02-28-2006 09:10 PM |
| fwrite throws segmentation fault | fermisoft | High Level Programming | 6 | 09-13-2005 01:46 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
grep throws in dashes?
Hey guys,
I'm trying to grep for two things out of a file and I got that working but why is it randomly throwing "--" in the output? Is there a simple way to get rid of them? It only seems to do it when the line above what im looking for has numbers in it. Code:
$ egrep -i -B 1 'port-name|description' in.txt 127.0.0.1 description -- 127.0.0.2 description -- 127.0.0.3 description helpme port-name yay port-name |
|
||||
|
See if this helps??
Hi,
I've seen something similar to this while using "gnu grep". If you simply grep for something, only those lines containing the search-pattern will be displayed. But if u issue "gnu grep -1 'search-pattern' file", you will get the lines immediately before and after the line containing the search-pattern. In your case, it gives the line just before the line containing search-pattern, i guess. There is a chance that your "egrep" may be aliased to "gnu egrep", or at least you are using the version of egrep inside the gnu folder. It would be kind of you, if you would explain the functionality of "-B" option. I wasnt able to ascertain.. Thanks, Srini Last edited by srinivasan_85; 04-27-2007 at 07:54 AM.. Reason: Typographical mistakes |
|
||||
|
Yea i'm using a GNU grep for this... "A" fetches lines below what you are looking for and "B" grabs lines above. I just created a perl script to strip them out before it writes to a new file. I'm terrible with using sed, awk, nawk etc.... so that was quickest fix for me.
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|