Generalize bash script