Be careful doing echo $something, its behavior depends on the IFS variable, and you could end up with disappearing character. You can try the following: var="hello world"; echo $var (two spaces between hello and world) or var="hello world"; IFS='l'; echo $var or var="-e hello \\n world"; echo $var. To solve that, put double quotes around the variable like this: echo "$var", or use printf. – jfgagneMar 1 '12 at 12:17
printf is very flexible and more portable than echo. Like the C/Perl/etc implementations, if you do not terminate the format string with \n then no newline is printed:
echo $something, its behavior depends on theIFSvariable, and you could end up with disappearing character. You can try the following:var="hello world"; echo $var(two spaces between hello and world) orvar="hello world"; IFS='l'; echo $varorvar="-e hello \\n world"; echo $var. To solve that, put double quotes around the variable like this:echo "$var", or useprintf. – jfgagne Mar 1 '12 at 12:17