Sunday, April 28, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1001  / 3 Years ago, wed, september 29, 2021, 7:38:58

I have a single-thread python script that gets used like this:




python -c "arg"




I also have a *.txt file with many arg, each in one single line in the respective *.txt. A text file, say 1.txt looks as follows:



arg1
arg2
arg3
arg4


Now I want to run the python script with all this arguments, one by one as the script does not allow more than one argument.



How can I process this arguments in batch mode using commandline?


More From » command-line

 Answers
7

One way:



for i in *.txt
do
while read line
do
python -c "$line"
done < $i
done

[#33262] Thursday, September 30, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bjecterless

Total Points: 59
Total Questions: 96
Total Answers: 105

Location: Argentina
Member since Thu, Mar 18, 2021
3 Years ago
bjecterless questions
;