Sed and Bash; unterminated 's' command
Greg
plug-discuss@lists.plug.phoenix.az.us
Wed, 19 Mar 2003 08:25:09 -0700
It has been a while since I have used sed but i think that pipes
supposed to be '/' (slashes)
another thing is to use single quotes in bash if you using string literally.
Greg
Mike Starke wrote:
>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?
>---------------------------------------------------
>PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
>To subscribe, unsubscribe, or to change you mail settings:
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
>
--
"Anger and Greed are the primary causes of defeat"
Sun Tzu - "Art of War"