Home > Software engineering >  How to represent formatted printf using echo in bash [closed]
How to represent formatted printf using echo in bash [closed]

Time:09-27

What is a command that produces the same output as the one below, without using printf?

printf 'sometext %s \t %s\n %s\n'

CodePudding user response:

If the echo on your System supporting -ne then you can define a function like...

$ puts(){(echo -ne "sometext ${1}\t ${2}\n ${3}\n")}
$ puts hello world bye
sometext hello   world
 bye

( Typed in a bash )

  • Related