printf command is used to print a formatted string in the standard output while interpreting ‘%’ directives and ‘\’ escapes to format numeric and string arguments in a way that is most similar to the C ‘printf’ function.
1 2 3 4 5 6 7 8 9 |
## string formatting printf hello world ## returns hello printf "hello world" ## returns hello world printf 'hello world' ## returns hello world printf "%s" "hello world" ## returns hello world printf "%s - %s" "hello" "world" ## returns hello - world printf "%s\t%s" "hello" "world" ## returns hello world printf "hello %s welcome to %s" "debjeet" "cloudaffaire" ## returns hello debjeet welcome to cloudaffaire |