![]() |
|
|
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 |
| Problem with GREP. | syndex | Shell Programming and Scripting | 2 | 07-11-2007 02:44 PM |
| grep problem | asal_email2 | UNIX for Dummies Questions & Answers | 4 | 06-22-2005 09:49 PM |
| grep problem | svennie | UNIX for Dummies Questions & Answers | 5 | 11-08-2004 04:29 AM |
| Grep Problem | lesstjm | Shell Programming and Scripting | 2 | 10-27-2004 11:13 AM |
| Grep problem | odogbolu98 | Shell Programming and Scripting | 3 | 02-18-2003 03:53 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Example:
bash wd/home/balamv bash:more test.txt hello hello-ssl welcome welcome-ssl hi bye bye-ssl seeyou I want to get all the lines which contain ssl and also the one does not contain ssl. Output should be like this. hello-ssl welcome-ssl hi bye-ssl seeyou Note if a line [ex. hello] has the ssl line, then get only ssl. How to achieve this? |
|
||||
|
It's not really a grep problem, per se. Code:
sed -n 's/-ssl$//p' test.txt | fgrep -vxf - test.txt This finds all the -ssl lines, and removes the -ssl suffix, then removes any lines matching any of these lines (-ssl lines with the -ssl suffix removed) from the original file. |
|
||||
|
No need to shout. What output did you get? The only possible problem I see with eras solution is if there is extra space after the "-ssl", but a slight modification fixes that: Code:
sed -n 's/-ssl\s*$//p' test.txt | fgrep -vxf - test.txt |
|
||||
|
\s is not a standard sed expression; you could use space and tab inside [ ] brackets instead. But I don't see any trailing spaces in the original example. If there are significant spaces, please use code tags when posting a sample.
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|