I have no idea if my Python is on the right track here, but with this example, I need to combine both r and f-strings whilst escaping a handful of characters in a particularly ugly command.
import subprocess
cust = input("Cust: ")
subprocess.run(r"""pd service:list -j | grep -i {cust} | awk '/name/ {print $0} /description/ {print $0} /summary/ {print $0 "\n"}' >> services_detailed.txt""".format(cust=cust), shell=True)
I have tried a few different methods, but this is the closest I have come to getting one to work.
A single r-string works absolutely fine (if I don't need to take user input), but when I need to take user input it becomes a problem.
Python syntax looks fine in VSCode but when running it spits out:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'print $0'
This doesn't really send me anywhere and I am not sure if I should be continuing with finding a way to get this string to work or going back to the drawing board.
I figured I would ask the question in case anyone else falls down the 'rf-string' rabbit hole.