Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to concatenate several bash commands in a python file. Doing that for one command works:
import os os.system('ls -l')
However if I dont know how to concatenate with another command like pwd
pwd
Use && and so:
import os os.system('ls -l && pwd')
This will execute pwd on the successful execution of "ls -l"
Add a comment
Use a semicolon if you want to always execute command 2, regardless of whether or not command 1 ran successfully:
import os os.system('ls -l; pwd')
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.