From 6161f40875e044e34b0875f95235417a6d5e20d3 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 14 Jun 2015 21:21:01 +0200 Subject: [PATCH] Optimized /proc/meminfo parsing Suggested by @jow- Signed-off-by: Nikos Mavrogiannopoulos --- net/transmission/files/transmission.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/transmission/files/transmission.init b/net/transmission/files/transmission.init index d9b52bb67..463e8ddb9 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