How to removing or delete non printable characters from expect file


Some character sequences from my files:
^[[64;8H, ^[[?25h, ^[[1;64r etc or avoid having expect add them in the first place.


I’m using a collection of expect scripts for certain tasks.

The output files I’m collecting often contain the above type of characters (as displayed in emacs / vi / cat -v).
I’ve tried a number of tr commands like the following but it only makes the [64;8H etc visible.

tr -dc ‘[:print:]\n’ < input EDIT: The results from above on a problematic line [1;64r[64;1H[64;1H[2K[64;1H[?25h[64;1H[64;..... answer: If you want to remove escape sequences as well, you can use the following sed snippet: sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" perl way: perl -pe ' s/\033\\\\\[(\d+;)*\d*[[:alpha:]]//g; s/\033\\\\\]0;//g; s/\x7//g; s/\033\(B//g; ' expect.log

how to know if a perl module is allready installed

we can use command like this:

perl -MModule::Name -e “print \”Module installed.\\n\”;”

example if I want to check if the Module Net::LDAP::Control::Persistent is installed I have to run this command

perl -MNet::LDAP::Control::PersistentSearch -e “print \”Module installed.\\n\”;”
In case that this module is Installed the console will print

Module installed
In case that this module is not installed the console will print something like this:

Can’t locate Net/LDAP/Control/ in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed–compilation aborted.