Really nothign to do with SE and everything to do with how browsers render <code>
tags. Double spaces (and tabs, etc) are munched down into single spaces.
If you want a proper code block, use four spaces at the beginning of the lines. This wraps the <code>
tag in a <pre>
which makes the browser behave more literally:
sudo apt-get remove $(dpkg -l|egrep '^ii linux-(im|he)'|awk '{print $2}'|grep -v `uname -r`); sudo apt-get upgrade
And your search is better represented by:
dpkg -l | awk '/^ii +linux\-(im|he)[a-z\-]+[0-9]/&&!/'"$(uname -r)"'/ { print $2 }'
A bit longer than yours but it won't remove meta-packages and hey, three commands, not five. It's still not perfect because in my situation, I've installed a new kernel but I'm not running on it yet. This sort of search would remove the newer kernel. Automating this stuff is dangerous.