Bash Performance Optimization