Reputation: 641
I am doing a show run > filename to save some cisco configs. It works fine, but on the save config there are those non printable characters that are annoying me.
It is showing in vim (also on other programs like kate) in this way:
aaa new-model
--More-- ^H^H^H^H^H^H^H^H^H ^H^H^H^H^H^H^H^H^H!
!
aaa authentication login default local
Instead of
aaa new-model
!
!
aaa authentication login default local
According to wikipedia (here), this character represents the backpsace keypress, and programs such as 'less' present it in the proper readable form. I don't know if this can be fixed on the origin, or disabled in vim at least, any suggestion is welcome.
Upvotes: 0
Views: 1698
Reputation: 124
I believe for this cisco outputs, you want to get rid of the whole --More--
line there. You can do so this way:
cat cisco-output.txt | grep -v '^ *--More.*\x08' > cisco-output-clean.txt
The result will look as:
aaa new-model
!
aaa authentication login default local
Upvotes: 0
Reputation: 123570
Here's a snippet that will naively try to treat the character as an erase character (cat -v
is used to show control characters in caret notation similar to opening the file in vim):
bash$ cat -v file
aaa new-model
--More-- ^H^H^H^H^H^H^H^H^H ^H^H^H^H^H^H^H^H^H!
!
aaa authentication login default local
bash$ sed -e $':b; s/.\b//; tb;' | cat -v
aaa new-model
!
!
aaa authentication login default local
This would get you closer to the actual terminal output than simply stripping all the erase characters.
Upvotes: 0
Reputation: 7689
You may just simply substitute all of them. For example,
:%s/<C-v><C-h>//g
Note that <C-v>
and <C-h>
mean ctrl-v and ctrl-h respectively. This allows you to insert unprintable characters (such as <C-h>
) into your substitute command.
This will remove all of them, but I can't guarantee the result will be formatted perfectly, since I'm not sure why they are there in the first place.
Upvotes: 3