-1

I have many lines of this format:

012343.ux002tesseract!Mat_server5.28746.1.0: Login ****** Oslo      -AXCVT2 - Versio 1.4 13.10.2016

Now I want to delete all the lines, which contain both 012343 and AXCVT2 in it.

As you can see the above line contains both of them.

jww
  • 97,681
  • 90
  • 411
  • 885
Kush
  • 39
  • 8
  • I don't see the line containing `012343`. Does the order matter? Ie. can `AXCVT2` be before and after `012343` and both such cases have to be removed? – KamilCuk Dec 05 '19 at 12:51
  • yes the order matter . 012343 always comes before AXCVT2 in these lines. – Kush Dec 05 '19 at 12:53

2 Answers2

2

That looks easy with sed, that can be learned from Sed - An Introduction and Tutorial by Bruce Barnett, which some knowledge of regular expressions, which can be easily learned from regex crosswords:

sed '/012343.*AXCVT2/d'

Would remove lines containing 012343 followed by anything followed by AXCVT2.

To remove lines that contain in both direction, we ex. can do two seds expressions:

sed -e '/012343.*AXCVT2/d' -e '/AXCVT2.*012343/d'

or shorter:

sed '/012343.*AXCVT2/d; /AXCVT2.*012343/d'
KamilCuk
  • 120,984
  • 8
  • 59
  • 111
0

This might work for you (GNU sed):

sed '/012343/{/AXCVT2/d}' file
potong
  • 55,640
  • 6
  • 51
  • 83