Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
784 views
in Technique[技术] by (71.8m points)

bash - Run all Python files in a directory

What is the best way to run all Python files in a directory?

python *.py

only executes one file. Writing one line per file in a shell script (or make file) seems cumbersome. I need this b/c I have a series of small matplotlib scripts each creating a png file and want to create all of the images at once.

PS: I'm using the bash shell.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

bash has loops:

for f in *.py; do python "$f"; done

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...