How can I remove lines from a file that match multiple patterns?

I have a file from which I'd like to be able to remove lines that match multiple patterns. For example, I might want to remove all lines containing 'AIX' and '5.3.'
babyb00merAsked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
So consider trying my awk solution!
0
 
omarfaridCommented:
try

grep -v "AIX*5\.3" filename

or if you mean AIX or 5.3 then try

grep -v "AIX|5\.3" filename
0
 
woolmilkporcCommented:
PAT1="AIX"
PAT2="5.3"

awk -v P1=$PAT1 -v P2=$PAT2 '{if ($0~P1&&$0~P2) next; else print}' inputfileoutputfile

wmp
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ozoCommented:
Do you want to remove lines which contain both  'AIX' and '5.3.'
or do you want to remove lines containing  'AIX'  and lines containing '5.3.' ?
0
 
ozoCommented:
If the latter

cat > patterns <<END
AIX
5.3.
END
grep -vFf patterns inputfile > outputfile
0
 
babyb00merAuthor Commented:
I'm sorry. Yes, the lines must contain both patterns.
0
 
omarfaridCommented:
did you try the grep command given?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.