I have a file that has a certain string on some lines that takes the form of either [Name](./path_to_name_directory)
or [Name](./path_to_name_directory/notes.md)
each with some unimportant list items. For the lines that do not have notes.md
at the end of the file path within the parenthesis, Name
gets prepended to that line.
To try and solve this, I originally had the following command
sed 's/\[(.*)\]\(\.\/.*\/(?!notes\.md)/\1&/g' ./file.md
but I eventually found out that sed does not support lookaheads or lookbehinds, so I moved to using perl to try and accomplish the same. I thought it would be as simple as doing
perl -pe 's/\[(.*)\]\(\.\/.*\/(?!notes\.md)/\1&/g'
but it did not work, and I'm not entirely sure where to go from here.
EDIT 1:
Sample Input File:
- [Name 1](./path_to_name_1)
- Unimportant list item.
- [Name 2](./path_to_name_2/notes.md)
- Unimportant list item.
Sample Output File:
- Name 1 [Name 1](./path_to_name_1)
- Unimportant list item.
- [Name 2](./path_to_name_2/notes.md)
- Unimportant list item.