Saving the output of a file as a variable
I currently have the following shell script:
Code:
while sleep 1 123456 12.66 13.99 1234.99 I need for this file to be printed out and each of these numbers saved as its own variable (id, width, length, speed) respectively. Can anybody help me as to how this would be done? |
Hi,
if you do the following: for i in `cat camdata` i is going to store iteratively each value of camdata. You need to add a loop of control of the number of parameters to get 4 times i, do your processing and go on. I don;t how to work the file line by line, but this method would work... |
I am not sure that I understand what you are saying. Where do you define what you want each instance of i to be? Would it be possible to give a more detailed explanation?
|
if camdata =
1 2 3 4 5 6 7 8 for i in `cat camdata` do echo $i done would give: 1 2 3 4 5 6 7 8 And in fact, i don't know how to read 4 times the input ..... Sorry, I don't help. I don't know awk enough to dare suggesting an alternative... |
Hello,
Quote:
http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html http://www-128.ibm.com/developerwork...ry/l-bash.html http://www.tldp.org/LDP/abs/html/ |
Code:
while read a b c d |
All times are GMT -5. The time now is 05:15 AM. |