How can I trim the carriage return from text that is being piped in bash?

view full story

http://unix.stackexchange.com – I'm using this command to get my last typed command: history | cut -c 8- | tail -n 2 | head -n 1 It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, annoyance, because I want just the command) and I'm piping this to the xsel clipboard manager: It also grabs the trailing new line / carriage return... I know in some shells you can use: echo "text \c" I'm not sure how to incorporate that into bash though. Extra points for the solution that is easiest to type on the fly :) (HowTos)