I would expect under bash for the following:
ls *.py | xargs -I{} echo $(echo {} | sed 's/\.py/_2\.py/g')
to list all .py files contained in the directory but with _2 annexed after the file name and before the .py extension.
Yet this is not what happens. It simply lists the .py files in the directory without any change.
In short:
$ ls
A.py B.py
$ ls *.py | xargs -I{} echo $(echo {} | sed 's/\.py/_2\.py/g')
A.py
B.py
while the output I expected would've been:
A_2.py
B_2.py
What happens here and how to get the expected output?