Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using a script to backup some Cisco routers and compare startup and running configs. My output is tarnished by some ssl certificates it returns - I wish to remove them.


*********  ERROR running diff on: AVE-1941-LAN config files Code: 0 ***************
 certificate self-signed 01                   |  certificate self-signed 01 nvram:IOS-Self-Sig#1.cer
  30820253 308201BC A0030201 02020101 300D0609 2A864886 F70D0 <
  31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E656 <
  69666963 6174652D 33393336 35313332 3733301E 170D3131 31323 <
  33355A17 0D323030 31303130 30303030 305A3031 312F302D 06035 <
  4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652 <
  31333237 3330819F 300D0609 2A864886 F70D0101 01050003 818D0 <
  81008EE9 17E0DDA9 B9ACAEEE 788267CD 1A6E7B99 15A1797E C1AFE <
  97F5E44A 7CA1E814 E329EEC3 1C6229CD 5C78C9FB F5107E23 FE386 <
  E7FA1849 BBA4884C 6001925E 6B2D2987 415AB429 ECDFCF87 E708D <
  C22F137C E5778EC0 E8F6A0FB 30A2EEF7 AB2E5E77 53F2D83B B7497 <
  8A5F0203 010001A3 7B307930 0F060355 1D130101 FF040530 03010 <
  551D1104 1F301D82 1B424553 2D313934 312D4176 652E796F 75726 <
  2E636F6D 301F0603 551D2304 18301680 14895C79 C998FF5B 08E1A <
  F3866724 C4301D06 03551D0E 04160414 895C79C9 98FF5B08 E1A23 <
  866724C4 300D0609 2A864886 F70D0101 04050003 81810002 DE0D3 <
  4708834D C2267F49 86A62B31 A505D0F9 79BBC295 1C8DB831 39467 <
  4A1F9149 DDB2ACDE CEE3DCB4 9CDAD85F 457D00BF BFBA3058 52188 <
  FD497E36 93C06D1D C35012B6 A61A35FC 88681759 C51F6C0A A79A9 <
  DB5391E9 49575BD5 50B6319E 065C2C99 4D9AB450 9D22D8         <

I would like to end up with;

*********  ERROR running diff on: AVE-1941-LAN config files Code: 0 ***************
 certificate self-signed 01                   |  certificate self-signed 01 nvram:IOS-Self-Sig#1.cer

Is this possible with a grep one liner with perhaps regex?

share|improve this question

Provided that the output is limited to what you have there, just getting rid of those unwanted lines would be:

grep -v '[0-9A-F]\{5\} <$'

To have the newlines removed as well, I'd probably pipe it into another grep command, since it's easy to read that way:

grep -v '[0-9A-F\{5\} <$' | grep -v '^$'
share|improve this answer

You could always use PERL or GAWK:

$ perl -ne 'print unless /<\s*$/' input_file


$ gawk '$NF!~/</'

Both scriptlets will print all lines that do NOT end with "<".

share|improve this answer

Using sed:

sed '/<\s*$/,/^\s*$/d'
share|improve this answer

try this

grep -v '^[0-9A-F]\{8\}'
share|improve this answer
Thanks for your answer, but it does not even apear to touch it.pastebin.com/HmTsVuH2 – Bryan Chapman Sep 13 '12 at 10:57
Try grep -v '^[[:space:]]*[0-9A-F]\{8\}.*[[:space:]]<$. It will remove all lines that that begin with at least 8 hex characters and end with < character. – Krzysztof Adamski Sep 13 '12 at 11:25
Perfect, many thanks – Bryan Chapman Sep 13 '12 at 11:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.