Unix: Writing more efficient shell scripts