Unix Shell - Problem with sed command

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2007 > Problem with sed command





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problem with sed command
jeniffer

2007-02-25, 1:25 am

Hi
I am writing a Makefile to extract the ELF executables from a
directory. I do

BINARIES := $(shell cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1
| sed s/ / $(BIN_DIR)/g )

On doing a make I get :-
sed: -e expression #1, char 2: unterminated `s' command

By doing cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1 I get the
list of binaries like
bin1 bin2 bin3 ..but I want to preappend the directory path to each of
the binaries . I thought to replace "space bin1" by "space$PATH bin1"
by sed command for all binaries but it is not working...Please help me
out.

Bill Marcum

2007-02-25, 1:25 am

On 24 Feb 2007 21:27:06 -0800, jeniffer
<zenith.of.perfection@gmail.com> wrote:
>
>
> Hi
> I am writing a Makefile to extract the ELF executables from a
> directory. I do
>
> BINARIES := $(shell cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1
>| sed s/ / $(BIN_DIR)/g )
>
> On doing a make I get :-
> sed: -e expression #1, char 2: unterminated `s' command
>

You need quotes.
| sed "s/ / $(BIN_DIR)/g" )


--
I fell asleep reading a dull book, and I dreamt that I was reading on,
so I woke up from sheer boredom.
Michael Paoli

2007-02-25, 1:25 am

jeniffer wrote:
> I am writing a Makefile to extract the ELF executables from a
> directory. I do
> BINARIES := $(shell cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1
> | sed s/ / $(BIN_DIR)/g )
> On doing a make I get :-
> sed: -e expression #1, char 2: unterminated `s' command


Let's see if this gives you some useful hints:
$ echo 'foo ' | sed s/ / whatever/g
sed: -e expression #1, char 2: unterminated `s' command
$ echo 'foo ' | sed -e 's/ / whatever/g'
foo whatever
$
Noteworthy question(s):
And where exactly does your sed editing script start, and where
does it end, ... and how do you expect sed to "know" this?
How do you expect sed to distinguish where any optional filename
arguments start?

references:
sed(1)
sh(1)
make(1)

Bo Yang

2007-02-25, 7:20 am

jeniffer :
> Hi
> I am writing a Makefile to extract the ELF executables from a
> directory. I do
>
> BINARIES := $(shell cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1
> | sed s/ / $(BIN_DIR)/g )
>
> On doing a make I get :-
> sed: -e expression #1, char 2: unterminated `s' command


You need quote here.
sed -e 's///g'

>
> By doing cd $(BIN_DIR) ; file * | grep ELF | cut -d ':' -f1 I get the
> list of binaries like
> bin1 bin2 bin3 ..but I want to preappend the directory path to each of
> the binaries . I thought to replace "space bin1" by "space$PATH bin1"
> by sed command for all binaries but it is not working...Please help me
> out.
>

I think your sed command should be as following:

sed -e "s%^%$(BIN_DIR)%g"

the above add the directory prefix to each bin.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com