Thursday, January 21, 2010

Bash History

A quick way to add a date/time stamp to your bash history:
export HISTTIMEFORMAT="::%h/%d - %H:%M:%S:: "

You can put it in your favorite bash start up file like .bash_profile or .bashrc

Thursday, January 14, 2010

How to convert a mac from Cisco/Foundry format to Unix format

I needed to associate servers to ports on our switches but the formats are different so I needed a way to convert them.

Here is a quick perl one line to go from Cisco/Foundry to Unix:
perl -ane '$_=~s/(..)\.?/\1:/g;$_=~s/:$//g; print $_'

An example:
echo 0019.b9f5.93f3 | perl -ane '$_=~s/(..)\.?/\1:/g;$_=~s/:$//g; print $_'
00:19:b9:f5:93:f3