bash rewrite