So, the following command works from the command prompt: sed -ne "s|^foobar[[:blank:]]|foo bar|p;p" processed_file Basically, replace foobar followed by a whitespace with foo bar Now, i'm trying to execute the same command in a bash script: #!/bin/bash sedrules="s|^foobar[[:blank:]]|foo bar|p;p" file=processed_file sed -ne $sedrules $file #done which errors out with: sed -e expression #1, char 27: unterminated `s' command I've googled and found out it has to do with bash and the quotes. Doing the same command at the command prompt, but without placing quotes around the expression, gives me the same error. But sedrules="'s/foobar//p'" doesn't work either. It gives me a sed error of unknown command Anybody come across this before and have any suggestions? Google pointed me in the right direction, but with no solutions.