variable value return of multiple command

I wrote this script

#!/bin/bash

var=`du -sch /var/log/messages;du -sch /var/log/maillog`
echo $var

I am getting result as follows.

# sh my.sh
2.1M /var/log/messages 2.1M total 296K /var/log/maillog 296K total

I need it like below

2.1M /var/log/messages 
296K /var/log/maillog

Can anyone help?

try echo -e $var

--ahamed

Try the following:

var=`du -h /var/log/messages /var/log/maillog`
echo -e $var

Well, the above doesn't work( I should test before I post ) but this should:

var=`du -h /var/log/messages /var/log/maillog`
printf "%s %s\n" $var

Thanks xbin, your second code worked fine. :slight_smile: