Activity for David
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #290322 |
Post edited: clarify one point |
— | 12 months ago |
Edit | Post #290322 | Initial revision | — | 12 months ago |
Answer | — |
A: How to extract string from file, run filter, and replace in file with new value? Both replies, at different points, provided the basis for this working script. Assuming that the 12th line of file has something like: ``` HERE IS MY TITLE ``` where `HERE...` begins at column 8 (I need to omit the opening `` tag, as noted in the original post), then: ``` for file... (more) |
— | 12 months ago |
Comment | Post #290287 |
I think I got it! This actually works (using your approach and structure):
for filename in chapter-*.xhtml; do
new12=$(sed -n '12p' "$filename" | cut -b 8- | se titlecase -n)
sed -i -e '12s#^\(.*<p>\).*#'"\1$new12"'#g' "$filename"
done
(Hopefully that will show as "... (more) |
— | 12 months ago |
Comment | Post #290287 |
Thanks for that - in this case (I think you'll see) the update was just to foreground something already in the existing question, not to alter it in any way. The existing answers still very much apply, and your `pup` suggestion already addressed it to some degree.
Thanks for the answer, and for th... (more) |
— | 12 months ago |
Edit | Post #290285 |
Post edited: typo tweak |
— | 12 months ago |
Edit | Post #290285 |
Post edited: add location of test data |
— | 12 months ago |
Edit | Post #290285 |
Post edited: update with further clarification |
— | 12 months ago |
Comment | Post #290287 |
Thanks @#8049 - helpful! I see from your answer (and even more the other one) that I need to edit my original post to clarify one point. But there is a pending edit which I don't have rep to approve, and it's blocking me being able to edit my own post. Could you (as mod) approve, then I can update? T... (more) |
— | 12 months ago |
Edit | Post #290285 | Initial revision | — | 12 months ago |
Question | — |
How to extract string from file, run filter, and replace in file with new value? TASK I am coding up ebooks to a specific standard, and have a script that converts a string into the correct titlecase for this publisher. When working with some public domain source files, one often gets this for a chapter title string:    `HERE IS MY TITLE` Using VSCodium (... (more) |
— | 12 months ago |