When using printf in bash scripts, it might accidentially happen that someone starts the formatting string with a "-" (hyphen/minus) character.
Printf will interpret this as parameter and (a) either do something that wasn't intended, or (b) throw the following error message:
[SOLUTION]bash: printf: - : invalid option
printf: usage: printf [-v var] format [arguments]
To solve this, the "-" sign has to be disarmed.
Add the string "--" as first argument before the format string and it should work.
Example:
Code: Select all
printf -- "- Name: %s" "$NAME"