|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using grep but printing a line more than once
Hi, I am using the grep function to grep some lines from a text file. However, a line is grepped only once even if it matches the strings in the first file more than once. How can i change the code so that the line gets printed more than once? Input file 1: Code:
1 o p 1 a b 2 3 c 5 6 7 Input file 2: Code:
o a c Desired Output: Code:
1 o p 1 a b 2 3 c Thanks! |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
This way: Code:
$ grep -E "$(sed 's/ /|/g;' file2)" file1 1 o p 1 a b 2 3 c Guru. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help with grep printing multiple lines. | m_usmanayub | Shell Programming and Scripting | 6 | 04-23-2012 08:32 AM |
| grep on string and printing line after until another string has been found | rxc23816 | Shell Programming and Scripting | 7 | 07-23-2011 05:49 PM |
| Help required on grep command(Skip the first few lines from printing in the output) | ks_reddy | Shell Programming and Scripting | 7 | 09-25-2009 10:40 AM |
| Need help in sed command [ printing a pattern + its line no or line no alone ] | frozensmilz | Shell Programming and Scripting | 4 | 06-28-2009 10:38 AM |
| printing the next line too?? | AndyA | Shell Programming and Scripting | 6 | 01-31-2008 05:35 AM |
|
|