Activity for David
| Type | On... | Excerpt | Status | Date |
|---|---|---|---|---|
| Edit | Post #290322 |
Post edited: clarify one point |
— | almost 3 years ago |
| Edit | Post #290322 | Initial revision | — | almost 3 years 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 ... (more) |
— | almost 3 years 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 ... (more) |
— | almost 3 years 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 fo... (more) |
— | almost 3 years ago |
| Edit | Post #290285 |
Post edited: typo tweak |
— | almost 3 years ago |
| Edit | Post #290285 |
Post edited: add location of test data |
— | almost 3 years ago |
| Edit | Post #290285 |
Post edited: update with further clarification |
— | almost 3 years 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 updat... (more) |
— | almost 3 years ago |
| Edit | Post #290285 | Initial revision | — | almost 3 years 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 VSCodi... (more) |
— | almost 3 years ago |
