Quick Answer: What Is the Difference Between Echo and Printf Statements in Linux?
Contents Echo Always Exits with a 0 Status, and Simply Prints Arguments Followed by an End of Line Character on the Standard Output, While Printf Allows for...
echo always exits with a 0 status, and simply prints arguments followed by an end of line character on the standard output, while printf allows for definition of a formatting string and gives a non-zero exit status code upon failure. printf has more control over the output format.
What is the difference between the print and echo commands?
echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument.
Must Read
Should I use echo or printf?
The only reason to use echo rather than printf is that the forma can be simpler. If you know what you’re printing, echo foo is faster and easier to type than printf ‘foon’ . Apart from that, when writing scripts where a variable needs to be printed, there’s never a good reason to use echo .