Page 1 of 1

SOLVED sed command works on command line not in bash

Posted: Tue Sep 08, 2020 1:08 pm
by sadhu
This sed stuff is driving me crazy.

I want to change <span class="note" id="n12"><span class="details"><span class="p">[n.12] to
<a class="fnref" id="t11" href="#n11">[11]</a>@@

This sed command works in the terminal:

Code: Select all

sed -i '0,/<span class=\"note\" id=\"n\(\w*\)\"><span class=\"details\"><span class=\"p\">/s//<a class=\"fnref\" id=\"t\1\" href=\"#n\1\">\[\1\]<\/a>\@\@/'
but as a bash script I get these errors:

Code: Select all

sed: -e expression #1, char 2: invalid usage of line address 0
sed: -e expression #1, char 3: unexpected `,'
Been trying to resolve this for 3 days.:(

Would be so grateful for help on this!

-sadhu

Re: sed command works on command line not in bash

Posted: Thu Sep 10, 2020 4:03 pm
by 1000
My script looks working.
It's probably a different line
This broken line contains " sed -e "
Edit
Or you have broken loop, I don't see script, so I can not check
Or you have just sed line ( but other ) broken.

Re: SOLVED sed command works on command line not in bash

Posted: Thu Sep 10, 2020 9:39 pm
by sadhu
Thanks for all your replies.

I broke the sed down into smaller pieces, and it now works. There apparently was a typo somewhere.