简体   繁体   中英

point a python script to run in multiple subdirectories

A python.py script lies in a directory that is above the directories date and data. Each data directory contains two ON and OFF directories as ~/dir_pyhton.py/dir_dates/dir_data/dir_ON, dir_OFF How can the python script be pointed to run in dir_ON and dir_OFF with a bash or tcsh command? - or another way?

You can use the find command to locate the ON and OFF directories, then pass them to the python script, like so:

cd ~/dir_pyhton.py/
find dir_dates/dir_data -type d \( -name "dir_ON" -or -name "dir_OFF" \) | xargs python python.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM