busybox (ash) compatibility & memory optimizations

changed bash syntax to ash syntax & used pipes instead of temporary files in /tmp to save memory