Harsh but fair

Open source chicanery and the battle with my inner geek

Archive for July, 2010

Embedded codes in the echo command \c etc

Posted by raetsel on July 26, 2010

Following on from a post a long time ago about migrating from HP-UX to RHEL I have found another “gotcha” in relation to the use of the echo command.

In HP-UX you can use terminal codes like \c for continue on same line and \n for new line etc.

In RHEL by default these codes are not interpreted. To get them to be interpreted you need to use “echo -e”

Here is a before and after

echo “Here is\t some\b \n\nembedded code”
Here is\t some\b \n\nembedded code
echo -e “Here is\t some\b \n\nembedded code”
Here is  som
embedded code
If you are only use \c codes you could consider removing them and just using echo -n to suppress the new line but I think echo -e is more flexible

Posted in Technical | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.