-1

Want to remove row which contains specific delimiter with different number of columns

                                         CPU Load for sdp4

7c:e5:3b:6e:2e:5f:d9:4d:68:4d:d5:57:3a:cb:4d:45.
  02:30PM   up 1 day,   9:20,  2 users,  load average: 6.88, 5.96, 5.57

In that case I want to remove everything with delimiter ":" :

7c:e5:3b:6e:2e:5f:d9:4d:68:4d:d5:57:3a:cb:4d:45.

I want remove any kind of this which contains that delimiter.

Expected view:

                                         CPU Load for sdp4

  02:30PM   up 1 day,   9:20,  2 users,  load average: 6.88, 5.96, 5.57
Kalin Borisov
  • 1,091
  • 1
  • 12
  • 23
  • 1
    But `02:30PM` contains `:`. What is the real problem you're trying to solve here and what have you tried by way of a solution? – johnsyweb Nov 26 '13 at 12:37

2 Answers2

1

try this grep line:

grep -Pv '^..(:..)+\.$' file

with your example:

kent$  echo "                                         CPU Load for sdp4

7c:e5:3b:6e:2e:5f:d9:4d:68:4d:d5:57:3a:cb:4d:45.
  02:30PM   up 1 day,   9:20,  2 users,  load average: 6.88, 5.96, 5.57"|grep -Pv '^..(:..)+\.$'                                                                                   
                                         CPU Load for sdp4

  02:30PM   up 1 day,   9:20,  2 users,  load average: 6.88, 5.96, 5.57
Kent
  • 189,393
  • 32
  • 233
  • 301
1

You could try:

grep -v ":..:" yourfile

That will remove all lines that contain a pair of colons separated by any two characters - which doesn't seem to appear in the lines that you do want.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432