Is it possible to have a command output in a sed pattern?
I have tried this:
sed -i 's/pattern/${python script.py}/gI' file.txt
Is it possible to have a command output in a sed pattern?
I have tried this:
sed -i 's/pattern/${python script.py}/gI' file.txt
Yes it's possible.
$ cat file.txt
pattern
pattern
aaaaa
bbbbb
$ cat python.py
print("hello")
$ python3 python.py
hello
$ echo $(python3 python.py)
hello
$ sed "s/pattern/$(python3 python.py)/gI" file.txt
hello
hello
aaaaa
bbbbb
Edit: (based on the comments) adding one example of why you should not use single quote
$ sed 's/pattern/$(python3 python.py)/gI' file.txt
$(python3 python.py)
$(python3 python.py)
aaaaa
bbbbb
Edit2: I removed the flag -i in the sed to test, it's easier you don't change your file until you have the desired result. For the final solution you should use the sed -i to have the file changed.