SOLVED sed command works on command line not in bash

Forum rules
Before you post please read how to get help
Post Reply
sadhu
Level 5
Level 5
Posts: 674
Joined: Fri Nov 22, 2013 9:48 am
Contact:

SOLVED sed command works on command line not in bash

Post 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
Last edited by sadhu on Thu Sep 10, 2020 9:38 pm, edited 1 time in total.
sabbe sattā bhavantu sukhitattā. LN 19.3-64 Cinn 4.4.8, Mobo: ASUSTeK STRIX B250G GAMING v, Dual core Pntm G4560, Intel Gfx. Laptop:ASUS, Core i3, 4G RAM Intel Gfx
1000
Level 3
Level 3
Posts: 134
Joined: Wed Jul 29, 2020 2:14 am

Re: sed command works on command line not in bash

Post 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.
sadhu
Level 5
Level 5
Posts: 674
Joined: Fri Nov 22, 2013 9:48 am
Contact:

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

Post 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.
sabbe sattā bhavantu sukhitattā. LN 19.3-64 Cinn 4.4.8, Mobo: ASUSTeK STRIX B250G GAMING v, Dual core Pntm G4560, Intel Gfx. Laptop:ASUS, Core i3, 4G RAM Intel Gfx
Post Reply

Return to “Scripts & Bash”