$ list="cricket frog cat dog" poem="I wanna be a x\n\ A x is what I'd love to be\n\ If I became a x\n\ How happy I would be.\n" for critter in $list; do echo -e ${poem//x/$critter} done $
Standard input is empty
I wanna be a cricket A cricket is what I'd love to be If I became a cricket How happy I would be. I wanna be a frog A frog is what I'd love to be If I became a frog How happy I would be. I wanna be a cat A cat is what I'd love to be If I became a cat How happy I would be. I wanna be a dog A dog is what I'd love to be If I became a dog How happy I would be.