Looping through the content of a file in Bash to get required output

Viewed 37

OK guys, i was wondering if anyone could help me with a loop i am struggling with, first off i want to start by saying i have next to no scripting knowledge so apologies if my terminology is not correct or i have explained poorly.

i have a set of commands in a textfile which i need to run, which i want to put in a loop. the commands needs to be fed into a executable with some flags either side

example of command in text file (multiple of these in text file which i want to be fed to executable):

add subs supi=imsi-100010004440017 k=xxxx opc=xxxxx algo=milenage

the desired output i want from the shell script / loop is:

/usr/XXX/execuable -c "Command from text file here " -u Admin -p Admin http://127.0.0.1

mu current shell script (which doesnt work

#! /bin/bash
Lines=$(cat /usr/XXX/text.txt)
for Line in $Lines
    do /usr/XXX/executable -c "$Line" -u Admin -p Admin http://127.0.0.1
done

i see many other forums suggest doing this but i have had no luck:

cat /usr/XXX/text.txt | while read line; do
    /usr/XXX/executable -c "$line" -u Admin -p Admin http://127.0.0.1
done
1 Answers
Related