mage
mage

Reputation: 23

sed command not working

pushd tests
mkdir -p $RPM_BUILD_ROOT%{_bindir}
for foo in $(make check-programs) ; do
 install -m 0755 .libs/$foo $RPM_BUILD_ROOT%{_bindir}
done
popd

sed command:

sed -i 's@for foo in $(make check-programs)@for foo in dristat drmstat@g'

o/p:

for foo in dristat drmstat$(make check-programs) ; do

expected:

for foo in dristat drmstat ;do

Can someone tell me what I am doing wrong?

Upvotes: 1

Views: 260

Answers (2)

Shirish
Shirish

Reputation: 47

Kindly take the data in file file1, then use this command:

cat file1|sed 's/\$\(make check-programs\)//g'

there is \ between $ and ( and between programs and )

Thanks.

Upvotes: 0

Kaz
Kaz

Reputation: 58667

Re: sed -i 's@for foo in $(make check-programs)@for foo in dristat drmstat@g'

I suspect this is not your actual script. Did you have double quotes in the real one by any chance chance?

# as in:
sed -i "s@for foo in $(make check-programs)@for foo in dristat drmstat@g"

Now you have an unescaped command substitution: $(make ...). Suppose that this runs in the environment where you are doing this sed job, and produces no output. The expansion of that argument is then:

s@for foo in @for foo in dristat drmstat@g

And that will produce:

for foo in dristat drmstat$(make check-programs) ; do

Upvotes: 2

Related Questions