I would like to use % as a normal character in printf lets say the output is a is 20% higher than b how would I be able to do that since % is used as a special character?
Asked
Active
Viewed 61 times
-2
-
1Try using it double `"%%"`. This is as in its parent C `printf` function. – Diego Sevilla Apr 27 '16 at 22:23
-
thanks did not knew it is the same as in C – Tenebris Apr 27 '16 at 22:30
-
@SureshKoya This should not be marked as a duplicate of that C question. This question is about bash even though the answer is basically the same. – Uyghur Lives Matter Apr 27 '16 at 22:53
2 Answers
1
Use double %
printf "hello%%"
Nicolas
- 127
- 1
- 10
-
1The OP is not asking about C, but the shell `printf` tool, that in the end also accepts the double %. – Diego Sevilla Apr 27 '16 at 22:25
1
You can escape it using %%.
printf "100%%\n"
Uyghur Lives Matter
- 18,820
- 42
- 108
- 144
JoseKilo
- 2,343
- 1
- 16
- 28