rewrite each using bash