I have a python script that print many commands if I execute python aaa.py
:
(base) tkl@TKL ~/Desktop python aaa.py
cp chart.xls ./me/chart.xls
find . | grep bro
scp -r [email protected]:/data/ti.exe .
Now I'm wondering if there's some linux command to execute these output as command sequencely and print all the output in the same shell, what I'm imaging is like that:
python aaa.py | xargs -i execute {}
Does such 'execute' exist?
CodePudding user response:
bash
is the normal processor to execute a bunch of shell commands. Like this:
{ echo date; echo ls; } | bash
So you could do this, if you trust your Python not to emit any "Bad Stuff" ™️
python aaa.py | bash
Or, similarly, as suggested in the comments, you may specifically mean a POSIX shell, or sh
, in which case:
python aaa.py | sh