Embedded codes in the echo command \c etc

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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s