Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-01-2012, 01:03 PM   #1
Registered: Jan 2012
Posts: 34

Rep: Reputation: Disabled
Revamping Linux Echo

On our UNIX system we use something like echo "All\nYes\nNo\n" in a popup box in COBOL which works fine, in linux however we need to do a echo -e "All\nYes\nNo\n"

rather than rewrite unknown lines of code to make this work, is there any way to make -e the default behavior of echo on linux?
Old 02-01-2012, 01:10 PM   #2
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,569

Rep: Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130Reputation: 2130
You could add an alias in your startup script

 alias bash='bash -e'
Old 02-01-2012, 02:44 PM   #3
Registered: Jan 2012
Posts: 34

Original Poster
Rep: Reputation: Disabled
works great on the command line...alias shows up under all profiles, but it still fails in cobol, am researching. thanks for the tip
Old 02-02-2012, 06:08 AM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
This is not a UNIX/LINUX thing. Since the POSIX standard doesn't specify which behavior should be the default, it's left up to the individual shell to decide how to implement it.

bash, the default shell on most linux systems, does not interpret baskslash forms by default, so you have to use the -e option. I believe ksh, on the other hand, does. I don't know about other shells.

You can use bash's xpg_echo shell option to enable automatic interpretation.

shopt -s xpg_echo

Edit: To tell the truth, I'm not sure what you mean exactly by using echo "in cobol". Could you perhaps be using the external /bin/echo in cobol programs?

If so, then the same issue as the above applies, and the gnu version of echo is also designed without automatic interpretation. I don't know if there's any way to tell it to do otherwise; the documentation doesn't mention anything.

If you really want to solve your problem at the root, try switching everything to use printf instead. It's more consistent across implementations.

Last edited by David the H.; 02-02-2012 at 08:08 AM. Reason: as stated


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
grep | xargs -I echo $(foo; bar; echo $(fee; fi; fo; fum)) == questionable output.. GrapefruiTgirl Programming 11 12-07-2010 07:02 PM
Revamping the server-client configuration in our lab vivek.sesha Linux - Networking 1 06-18-2007 10:00 AM
ls | echo, I got blank, why can't echo take the 2nd seat in a pipeline? elinuxqs Linux - Newbie 6 11-24-2006 08:25 AM
LXer: Revamping the Web Browser LXer Syndicated Linux News 0 06-12-2006 04:33 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration