loading args from file with multiple lines
Greetings
Happy new year I have a file "myfile.txt" which has the following content and this content is used as arguments for my script: 10 1203 88 1010 76 765 1 122 I made a script which performs some calculations and i run it as follows: myscript.sh 10 1203 How can i load each line from the file to the script. In other words, i want the scrip to perform the calculations for each line in the file. Thanks |
Hi,
Something like this should do the trick I guess: Code:
cat myfile.txt | while read F |
Quote:
Yes id does the trick :-D Is it possible to embed this functionality within the script myscript.sh For example: Code:
While reading lines from myfile.txt |
Quote:
Glad it worked. You can embed the loop in your script: Code:
# myscript.sh Code:
./myscript.sh myfile.txt Louis |
@tripialos: If there is just one myfile.txt (or alike) you can simplify the above:
Code:
#!/bin/bash If you have to be able to use different input files you can do this: Code:
#!/bin/bash |
sorted with both solutions!!!!
Thanks guys!! |
All times are GMT -5. The time now is 11:55 PM. |