0

I'm using the following command to capture the diskspace used on my server and store it in the var space.

space=`cd /users/; du -hs * | sort -h;` 

at the command line entering echo "$space" shows the correct output with the line feeds for the results.

I'm now trying to email this to myself, the email sends fine but the du output all appears on one line not new lines like it does at the bash prompt.

This is my mail body and how I'm trying to use space.

It works, but the output is not showing as it would when run from the command line.

mailbody="$server_name - Server disk usage is at ${current_usage}. ${space}"

eg. I get

Test Server - Server disk usage is at 40%. 1.1G jon 1.1G paul 1.9G ringo

where I'd like to get

Test Server - Server disk usage is at 40%. 
1.1G jon 
1.1G paul 
1.9G ringo

Any idea how I can do that ?

Thanks

Rocket
  • 1,065
  • 2
  • 21
  • 44

1 Answers1

-1

The solution is:

space=$`cd /users/; du -hs * | sort -h;`

The $ makes the ansi-c standard codes expanded. Even form feeds and alerts work.

Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31