what r the diferences b/w printf and echo cmd.........
is use of printf better than echo? how...........
what r the diferences b/w printf and echo cmd.........
is use of printf better than echo? how...........
well, it depends on what you want to do
if you want just a basic display, echo is enough
printf allows you to display with formatting features. If you're
familiar with c, it's similar to c's printf
I'll give you some examples
# i=5
1. echo
# echo $i
5
#
2. printf
# printf $i
5#printf "$i\n"
5
#
# printf "%02d\n" $i
05
#
As you must have noticed with printf the
newline character '\n' is not automatically added as in
echo
The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.
Join / Linux Training / Board