add new line to bash script output
I am trying to send a small report via email using this bash script
Code:
#!/bin/bash Code:
--------------------------------- Host Name: raspberrypi --------------------------------- Date: Fri Feb 25 13:29:57 GMT 2022 --------------------------------- CPU Usage: 3% --------------------------------- Disk Usage: 5% --------------------------------- Memory Usage: 5% --------------------------------- Temperature: 45C --------------------------------- Uptime: 4 days --------------------------------- Local IP: 192.168.1.212 --------------------------------- Public IP: 139.138.204.42 --------------------------------- |
Add double quotes - echo "$report"
|
thank you
|
That applies for all variables, not just report.
ShellCheck is a useful tool for checking things like this. |
The shell often expands unquoted $variables.
Often means: in commands and lists. echo is a command; put quotes! If you are in doubt if quotes are needed then put quotes! Within " " (double quotes) the shell evaluates+substitutes $-expressions, such as ${variable} or $(command) or $((arithmetic)), but does not do word splitting and filename generation. In this case the word splitting lead to the replacenment of newlines by spaces. For completeness: Within ' ' (single quotes, ticks) everything is literal; the shell does no substitution or expansion. |
All times are GMT -5. The time now is 07:17 PM. |