2

I have a python script called x, I also have a text file. how do i create a bash script to execute the command based on the line? for example: script name x text name test

i want the bash script to select each line and do:

python x.py $line >>log.txt

then go to the next line and do

python x.py $line2 >>log.txt

an so on

1

1 Answer 1

2

This should work for you.

#!/bin/bash
filename=textFileName
while read -r line
do
python x.py $line >>log.txt
done < "$filename"
Sign up to request clarification or add additional context in comments.

1 Comment

thank you very much. this works. how about adding sleep time between executions ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.