Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

egrep "| N1" and "| N2" and "| N3" from file 1

Status
Not open for further replies.
Feb 12, 2002
80
0
0
NO
Hi,

Simply really ... I have a pipe delimited text file and want to grep everything except the following text:
Code:
| N1
| N2
| N3
| N4
| N5
| N6
| N7
| N8
| N9

I have searched the FAQ's and this forum, but not really getting anywhere.

I think egrep and an input file listing my text will work, so I have a file as above called strings.txt but the following fails:

Code:
egrep -e strings.txt pipe_delim.txt

any ideas?

 
egrep -[!]f[/!] strings.txt pipe_delim.txt

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks - but no joy ...

Code:
% more strings2.txt
| N1
| N2
| N3
| N4
| N5
| N6
| N7
| N8
| N9
% egrep -f strings.txt pip_delim.txt
egrep: syntax error
%
 
sorry - strings2.txt should be strings.txt

I have tried it with

"| N1"
and
| N1
 
You may try this:
\| N1
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ah ha - that works ...

Code:
egrep "\| N1|\| N2" pipe_delim.txt

Many thanks (yet again) to PHV
 
Try :
Code:
fgrep -f strings.txt pipe_delim.txt

Jean-Pierre.
 
Another way:
grep '| N[1-9]' pipe_delim.txt

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top