Sed and Bash; unterminated 's' command

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mike Starke
Date:  
Subject: Sed and Bash; unterminated 's' command
On Wed, Mar 19, 2003 at 08:01:20AM -0700, Liberty Young wrote:
/_
/_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.
/_

Far from my specialty, but maybe you need to escape the | (pipe) character?