I am very new to bash scripts. I have a .txt file with string names separated by lines (have space between each string).
my.txt is:
my name
my class
my room
When I run my python script using terminal. I need to pass arguments one by one.
python3 python_file.py -f 'my name'
python3 python_file.py -f 'my class'
python3 python_file.py -f 'my room'
It works fine. I want to use bash script for each string (my name, my class, and my room) individually and pass as an argument for a python script.
#!/bin/bash
while read LINE; do
#echo ${LINE}
python3 pythonfile.py -f $LINE
done < my.txt
It doesn't work as each string has a space between them (my name), python assumes as string and display error message
error: unrecognized arguments: name
When I ma trying to put quotes in bash script, it is not working.
#!/bin/bash
while read LINE; do
echo \'${LINE}\'
#python3 pythonfile.py -f $LINE
done < my.txt
output:
'my name
'my class
'my room
with same error message.
When I tried to put quotes inside .txt file, it doesn't even work then.
new: my.txt
'my name'
'my class'
'my room'
same error message:
error: unrecognized arguments: name
I do not want to do it with one python script by reading names one by one from my.txt file. I have some internal coding in python script that is not suitable for this. Hence I want to use bash.
Please guide.