Skip to main content

Timeline for sed to replace path to the image

Current License: CC BY-SA 4.0

14 events
when toggle format what by license comment
Oct 4, 2021 at 11:39 comment added minto still not work, no errors, but don't change path. Btw, some links are <img src="/api/v2/epubs/urn:.. and some<img class="icon1" src="/api/v2/epubs/urn:.. if that matter.
Oct 4, 2021 at 11:23 history edited Kusalananda CC BY-SA 4.0
deleted 3 characters in body
Oct 4, 2021 at 11:23 comment added Kusalananda @minto It seems I have misspelled the option. How irritating. The option should be written --inplace or -L. I will update my answer.
Oct 4, 2021 at 11:20 comment added minto no, I used your example above, after words "using a simple shell loop." The files are already XML-compliant as they were recovered before through the xmlstarlet. Or it's not?
Oct 4, 2021 at 11:08 comment added Kusalananda @minto Did you try using --in-place with xmlstarlet fo?
Oct 4, 2021 at 11:05 comment added minto I tried shell loop sample for name in ./*.xhtml; do ...., but it show Warning: unrecognized option '--in-place' Segmentation fault for each file.
Oct 4, 2021 at 5:48 comment added Kusalananda @minto If you look a bit further up, in my answer, you will find a pipeline that runs a document throughxmlstarlet fo and then pipes it to xmlstarlet ed. It would be trivial to use that in the loop to write the resulting documents to new files.
Oct 3, 2021 at 23:34 comment added minto I tried this command xmlstarlet ed -u '//img/@src[. = "/api/v2/epubs/urn:orm:book:381260143574/files/"]' -v 'graphics/' file.xhtml but it doesn't change image path on stdout.
Oct 3, 2021 at 12:05 comment added minto first I need normalize all .xhtml files, as xmlstarlet can deal only with properly formatted XML documents. Not clear, how to use this shell loop first for filtering the XHTML files through the xmlstarlet fo --recover --html file.xhtml and saving output as files. Without first formatting .xhtml docs, xmlstarlet just print a plenty warnings "Opening and ending tag mismatch:", "Premature end of data in tag","Warning: unrecognized option '--in-place', Segmentation fault".
Oct 3, 2021 at 6:00 comment added Kusalananda @minto See updated answer.
Oct 3, 2021 at 5:59 history edited Kusalananda CC BY-SA 4.0
added 1119 characters in body
Oct 2, 2021 at 22:37 comment added minto how to batch process multiple .xhtml files in above example?
Sep 26, 2021 at 6:21 history edited Kusalananda CC BY-SA 4.0
added 457 characters in body
Sep 25, 2021 at 22:41 history answered Kusalananda CC BY-SA 4.0