I want to replace a unique string in a markdown file with another unique string located in a separate text file.

I would like to do this with basic Linux commands that I can run with GitHub actions.

To generate the unique string that I want to replace, I:

grep -Po '(?<=href=")[^"]*(?=")' filename | head -1 > replace.txt

Next I want to search a file, locate the string found in replace.txt, and overwrite it with a string found within inject.txt (inject only contains the unique string).

1 Answer 1


I found a suitable way to replace it with the use of variables like so:

sed -i~ -e"s@$s1@$s2@g" file_to_edit

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .