[bash]
#!/bin/sh
OFF="$1"
UNIT="$2"
OUTPUT_FROM_DF_AND_AWK=$(free -m | awk ’IF NR == 2 {print $4"%s%s"$2"%s\n"}’)
for LINE in $OUTPUT_FROM_DF_AND_AWK
do
printf $LINE "$UNIT" "$OFF" "$UNIT";echo " ";
done
[/bash]
[bash]
peter@E5410:~$ memory.sh " av " "MB"
2643MB av 7799MB
[/bash]