awk for Regular Expressions Query #41
Replies: 2 comments
-
Nice! I'm trying to figure out this bit by bit, so I'll do a simple summary in my own words, just so that I can analyse this a bit:
Can you please do small improvements:
Have a great day, too! 🙂 You have clearly come up with ideas that let you use this plugin in ways that would have never come to my mind! 😎 |
Beta Was this translation helpful? Give feedback.
-
@Taitava !!!!! The whole story about this is here in the post for the fantastic Apply Patterns plugin. That’s why this
No, you are right. I just select and copy to clipboard.
After this step, I have another regex in Apply Patterns that erases only
As far as I know, yes we can do a find and delete with AWK (but I don’t know how) I happy to share this with you !!! Now you are seeing why this is so important to me :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello @Taitava and Friends!
This is a post to show how to use Shell Commands to select/copy content from a note using the
awk
command.User Case
I have .md files generated from a App (DEVONthink) that I use for highlight Web Articles. This App let me highlight web articles and generate a .md file only with the highlights.
This App generates a URL from every highlight that I do. This way, I can track the origin of the highlight inside the original article in the App
[L4](x-devonthink-item://C5A952D4-8CB9-4CA9-9B3A-BC397B08C1F6?line=3)
The problem is that the url schema is not placed that I want. I need to select all these URL and transfer to another placed in the note.
I am on MacOS and Obsidian 0.12.15
AWK
After a long search I found a command called
awk
that is used to select text inside a note based on a bunch of criteria.For my need I need to copy all URL to the clipboard to be pasted in the end of the note
What worked for me is this:
awk 'match($0, /regex/) {print substr($0, RSTART, RLENGTH)}' "/{{file_path:absolute}}" | pbcopy
$0
In my case:
awk 'match($0, /\[L[0-9]*\]\(x-devonthink-item:\/\/[a-zA-Z0-9_]*-[a-zA-Z0-9_]*-[a-zA-Z0-9_]*-[a-zA-Z0-9_]*-[a-zA-Z0-9_]*\?line\=[0-9]*\)/) {print substr($0, RSTART, RLENGTH)}' "/{{file_path:absolute}}" | pbcopy
This is the result:

If you think there is a better way to do this, please let me know!!!
I hope it helps someone with the same workflow.
Have a great day!
Beta Was this translation helpful? Give feedback.
All reactions