I want to replace all instance of abc
with 123
provided it isn't preceded by https://
.
Code:
file=Data.txt
Initial="# Start";
orig="abc";
new="123";
Final="$" # Line Number
sed -r -e "/${Initial}/,${Final}s/${orig}/${new}/g" ${file} # Final doesn't accept $
Data:
# Start
abc.md
https://abc.md
The path is https://abc.md for abc.md
The path for abc.md is https://abc.md
Expected Output:
# Start
123.md
https://abc.md
The path is https://abc.md for 123.md
The path for 123.md is https://abc.md
How can I achieve this?
Note: I also need to use ${Initial}
and ${Final}
to denote between which the pattern might exist.
This answer doesn't work for the case The path is: https://abc.md abc.md