From: Nikos Mavrogiannopoulos Date: Sun, 14 Jun 2015 19:21:01 +0000 (+0200) Subject: Optimized /proc/meminfo parsing X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6161f40875e044e34b0875f95235417a6d5e20d3;p=feed%2Fpackages.git Optimized /proc/meminfo parsing Suggested by @jow- Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/net/transmission/files/transmission.init b/net/transmission/files/transmission.init index d9b52bb672..463e8ddb91 100644 --- a/net/transmission/files/transmission.init +++ b/net/transmission/files/transmission.init @@ -57,7 +57,7 @@ transmission() { config_get download_dir "$cfg" 'download_dir' '/var/etc/transmission' config_get mem_percentage "$cfg" 'mem_percentage' '50' - local MEM=$(grep MemTotal /proc/meminfo|sed 's/ \+/ /g'|cut -d ' ' -f 2) + local MEM=$(sed -ne 's!^MemTotal:[[:space:]]*\([0-9]*\) kB$!\1!p' /proc/meminfo) if test "$MEM" -gt 1;then USE=$(expr $MEM \* $mem_percentage \* 10) fi