Simplify these bash scripts nonsense