execute bash commands on a directory utilizing node child processes with timeouts.
- command (use $ as placeholder for filepath)
- directory
- (optional) file end to filter directory by
- TIMEOUT (ms, default: 30000ms)
- install tsc
yarn install
- build
yarn build
- execute 'head -n 1' command on every csv in directory
node dist/src/index.js "head -n 1 $" /home/user/csvs .csv
- copy all .txt files in /usr/bin to '/new' directory
node dist/src/index.js "cp -r $ /new" /usr/bin .txt
- mv all .csv files in /usr/bin to /data with 5s timeout
TIMEOUT=5000 node dist/src/index.js "mv $ /data" /usr/bin .csv
.
- I built this tool to execute python scripts on a directory of csv files. The py scripts take a single filename as an argument and do some processing.
node dist/src/index.js "python3 myscript.py $" /dir/of/csvs .csv