Skip to main content
added 124 characters in body
Source Link
jlliagre
  • 62.5k
  • 11
  • 124
  • 162

For trivial messages (no escape sequences, no options), echo is fine. As soon as you need something more complex, you shoud use printf which is portable (i.e. behave the same regardless of the OS) and allows much better formatting, being designed from the same name C function.

Should you want to call echo in your example, the correct way would be either:

echo -n "blah" >/dev/udp/localhost/8125 

or

echo "blah\c" >/dev/udp/localhost/8125 

depending on the echo implementation you use.

For trivial messages (no escape sequences, no options), echo is fine. As soon as you need something more complex, you shoud use printf which is portable (i.e. behave the same regardless of the OS) and allows much better formatting, being designed from the same name C function.

For trivial messages (no escape sequences, no options), echo is fine. As soon as you need something more complex, you shoud use printf which is portable (i.e. behave the same regardless of the OS) and allows much better formatting, being designed from the same name C function.

Should you want to call echo in your example, the correct way would be either:

echo -n "blah" >/dev/udp/localhost/8125 

or

echo "blah\c" >/dev/udp/localhost/8125 

depending on the echo implementation you use.

Source Link
jlliagre
  • 62.5k
  • 11
  • 124
  • 162

For trivial messages (no escape sequences, no options), echo is fine. As soon as you need something more complex, you shoud use printf which is portable (i.e. behave the same regardless of the OS) and allows much better formatting, being designed from the same name C function.