I have a shell program that has content like this
!#/bin/bash
echo \\n program
Once I run this program on a platform other than Linux it recognizes the special character and gives the output as
(newline)
program
When the same program runs on Linux, the echo command needs the "-e" option. Now I don't want to change each occurrence of echo with "echo -e" in my file explicitly because then this will start creating issues on other platforms. So I want to do a conditional compilation like
set SYSTEM="uname -s"
#if ($SYSTEM == Linux)
set echo="echo -e"
#endif
but this does not work because using the set or export command, I need to replace all occurrences of echo with $echo, which I don't want to do. Again setting aliases does not solve this issue as i need echo to be replaced with "echo -e" even in subshell.
Is there any other way around with which I can substitute echo with "echo -e" only for Linux platform?